[jQuery] jQuery Validation - ajax check for email
Hi,
This is my first attempt at using addMethod and it's always returning
true, for some reason.
This is placed outside of document.ready
jQuery.validator.addMethod("checkemail", function(email) {
var email = $('#email').val();
$.post("user/checkemail", { "email" : email },
function(data){
if(data.exists == "1")
{
return true;
}
}, "json" );
}, 'This email already has already been registered');
and in the validate() method, I'm calling the function like this:
rules:{
email: {
required: true,
email: true,
checkemail: true
}
}
Is there anything obvious i'm doing wrong here?
Thanks!