$(document).ready(function() { function passwordcomplex(value){ password = value; if((password.length < 6) || (password.length > 10)){ return false; } var hasUpperCase = /[A-Z]/.test(password); var hasLowerCase = /[a-z]/.test(password); var hasNumbers = /\d/.test(password); var hasNonalphas = /\W/.test(password); if (hasUpperCase + hasLowerCase + hasNumbers + hasNonalphas < 4){ return false; }else{ return true; } } function securitycodecheck(){ var scode = $('#securitycode').val(); var pattern = /^[A-Za-z0-9]{6}$/; if (pattern.test(scode)) { return true; } else { return false; } } function isAlphaNum(username){ if((username.length < 4) || (username.length > 10)){ return false; } if (/[A-Za-z0-9]/.test(username)) { return true; } else { return false; } } $('#palmsLogin').live('click',function(){ $('.error').html(''); var uid = $('#loginid').val(); var pass = $('#password').val(); var sid = $('#sid').val(); uid = uid.trim(); if(isAlphaNum(uid) && uid != '' && passwordcomplex(pass) && securitycodecheck()){ salt_pass = 91277; var username = $('#loginid').val(); var password = $('#password').val(); var securitycode = $('#securitycode').val(); password = MD5(MD5(password)+salt_pass); username = salt_pass+(username)+salt_pass; $('#password').val(password); urlL = 'include/logincheck.php'; Rurl = 'home.php'; $.ajax({ type: "POST",url: urlL,dataType: 'json',cache: false, contentType:"application/x-www-form-urlencoded",timeout: 30000, data: { uid : username,pass : password,securitycode : securitycode,sid : sid }, error: function(a,b,c){ $('.error').html('Login failed...'); }, success: function(msg){ if(msg.success){ document.location.href = Rurl; }else{ $('#password').val('');$('#loginid').val(''); $('#securitycode').val('');$('.error').html(msg.error); } } }); }else{ $('.error').html('* Invalid User Credentials..'); return false; } }); });