Advertisement
joris

jQuery Mobile

Aug 8th, 2012
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.68 KB | None | 0 0
  1. <script language="javascript">
  2.    
  3.     $(document).ready(function(){
  4.         $("#submit").click( function (){
  5.             var username = $('#username').val();
  6.             var password = $('#password').val();
  7.             var token="";
  8.             var nama="";
  9.             var status="";
  10.             var lastlogin="";
  11.            
  12.             if(username !='' && password !=''){
  13.     if (username.indexOf("\"") != -1 || username.indexOf("'") != -1 || username.indexOf("<") != -1 || username.indexOf(">") != -1){
  14.                     jAlert('Ada karakter aneh di field username', 'Forbiden Rules');
  15.                     }// Ini tutup if jika Ada karakter aneh
  16.                      else{
  17.             $.ajax({
  18.                type: "POST",
  19.                url : 'http://www.berthojoris.com/login_cek.php',
  20.                cache: false,
  21.                data: {
  22.                   username:$('#username').val(),
  23.                   password:$('#password').val(),
  24.                },
  25.                dataType: "json",
  26.                success: function (data) {
  27.                     if (data.response=='SuksesLogin') {
  28.                         ClearForm();
  29.                         self.location="menu_admin.html";
  30.                     } else {
  31.                         jAlert('Username dan Password tidak cocok', 'Login Failed');
  32.                         ClearForm();
  33.                     }
  34.                 },
  35.                 error : function(data) {
  36.                        jAlert('Koneksi anda sedang bermasalah.', 'Check Connection');
  37.                }
  38.       });
  39.                     }
  40.  
  41.                 }else{
  42.                     jAlert('Field masih ada yg kosong', 'Field Empty');
  43.                     document.forms["login"]["username"].focus();
  44.             }
  45.        
  46.     });
  47. });
  48.  
  49.    
  50.     function ClearForm(){
  51.         document.forms["login"]["username"].value = ""
  52.         document.forms["login"]["password"].value = ""
  53.         document.login.username.focus();
  54.     }
  55.  
  56. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement