SHARE
TWEET

Untitled

a guest Dec 8th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready( function () {
  2.     $('#areaDT').DataTable();
  3. });
  4.  
  5. function save() {
  6.     var name = $("#name").val().toUpperCase();
  7.     var description = $("#description").val().toUpperCase();
  8.     var regexSpesialChar = /^[a-zA-Z0-9 ]+$/;
  9.     var regexNumeric = /^[0-9]+$/;
  10.  
  11.     if(name == "" || description == ""){
  12.         swal('Peringatan', 'Tolong lengkapi data dengan benar!', 'warning');
  13.     } else {
  14.         if(name.match(regexSpesialChar) && description.match(regexSpesialChar)){
  15.             $.ajax({
  16.                 cache: false,
  17.                 dataType: "json",
  18.                 type: "post",
  19.                 url: "http://localhost/saber-cia/area/save",
  20.                 data: {name : name,
  21.                     description : description},
  22.                 success: function(res){
  23.                     if(res.code == 200){
  24.                         swal('Berhasil', 'Kamu berhasil menambahkan data baru!', 'success');
  25.                     } else {
  26.                         swal('Gagal', 'Kamu gagal menambahkan data baru!', 'error');
  27.                     }
  28.                 }
  29.             });
  30.         } else {
  31.             swal('Peringatan', 'Format data tidak valid!', 'warning');
  32.         }
  33.     }
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top