I am validating a form on a registration page, everything works properly except the email validation is a bit hit and miss.
It works fine if I just validate it to make sure it's an actual email address, but when I try to add a check to see if its in use as well I run in to problems.
The validation itself works fine, but the form won't submit once its validated and not in use.
This works, and the form submits:
if(filter.test(a)){
email.removeClass("field_error");
emailInfo.text("");
emailInfo.removeClass("error");
return true;
}
This works, but the form does not submit:
if(filter.test(a)){
$.post('php/availability.php',{email: $('#email').val()}, function(emaildata){
if(emaildata.exists){
email.addClass("field_error");
emailInfo.text("(Email address in use)");
emailInfo.addClass("error");
} else {
email.removeClass("field_error");
emailInfo.text("");
emailInfo.removeClass("error");
return true;
}
}, 'JSON');
}
I'm stumped.