Advertisement
jamboljack

Update Profile

Sep 19th, 2017
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.15 KB | None | 0 0
  1. $(document).ready(function() {
  2.     $("#formInputProfil").validate({
  3.         rules: {
  4.             nik: {
  5.                 required: true, minlength: 10, number:true
  6.             },
  7.             nama: {
  8.                 required: true, minlength:5
  9.             },
  10.             jabatan: {
  11.                 required: true
  12.             }
  13.         },
  14.         messages: {
  15.             nik: {
  16.                 required:'NIK harus di isi', minlength:'NIK minimal 10 karakter', number:'NIK harus angka'
  17.             },
  18.             nama: {
  19.                 required:'Nama Lengkap harus di isi', minlength:'Nama Lengkap minimal 5 karakter'
  20.             },
  21.             jabatan: {
  22.                 required:'Jabatan harus di isi'
  23.             }
  24.         },
  25.        
  26.         submitHandler: function(form) {
  27.             dataString = $("#formInputProfil").serialize(); // Ambil Value dari Form
  28.             $.ajax({
  29.                 data: dataString,
  30.                 url: "<?php echo site_url('profile/updatedata'); ?>",
  31.                 type: "POST",
  32.                 success: function(data) {
  33.                     setTimeout(function() {
  34.                         swal({
  35.                             title:"Sukses",
  36.                             text: "Update Profil Berhasil",
  37.                             timer: 2000,
  38.                             showConfirmButton: false,
  39.                             type: "success"
  40.                         }, function() {
  41.                             window.location="<?php echo site_url('profile'); ?>";
  42.                         })
  43.                     });
  44.                 },
  45.                 error: function() {
  46.                     setTimeout(function() {
  47.                         swal({
  48.                             title:"Gagal",
  49.                             text: "Update Profil Berhasil",
  50.                             timer: 2000,
  51.                             showConfirmButton: false,
  52.                             type: "error"
  53.                         }, function() {
  54.                             window.location="<?php echo site_url('profile'); ?>";
  55.                         })
  56.                     });
  57.                 }
  58.             });
  59.         }
  60.     });
  61. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement