jquery validation remote method ajax
by Prakash[ Edit ] 2014-04-11 15:48:36
Check if an email is already registered in jquery validation. For this we use remote attribute in jquery validation plugin :
javascript file:
$(function(){
$("form.signupform").validate({
rules:{
email:{
required:true,
email:true,
remote:{
url:"email-not-registered.php",
type:"post"
}
}
},
messages:{
email:{
remote:"This email is already taken. Choose another."
}
}
});
});
php file:
function isEmailRegistered{
//check email registered or not
}
if(isEmailRegistered()){
echo "false";
}else{
echo "true";
}