Reputation: 737
I have the following code, validation works fine, but it doesnt submit
jQuery("#form_driver").validate({
submitHandler: function(form) {
//check if email exists
jQuery.ajax({
type: "POST",
url: "checkmail.php",
data: ({
email: jQuery("#email").val()
}),
cache: false,
success: function(data)
{
if(data == 0) {
alert("Email doesnt exist");
return false;
}else if (data==1){
alert("The Email is already linked to your location!");
return false;
}else if (data==2){
jQuery("#form_driver").submit();
return true;
}
}
});
}
});
Unbelievable what it outputs to the console, Its driving me crazy, it iterates forever, I had to stop it manually
Upvotes: 2
Views: 776
Reputation: 2623
You need to submit the form passed to the submitHandler. You are reselecting the form via jQuery instead. See the api.
Try this instead:
jQuery("#form_driver").validate({
submitHandler: function(form) {
//check if email exists
jQuery.ajax({
type: "POST",
url: "checkmail.php",
data: ({
email: jQuery("#email").val()
}),
cache: false,
success: function(data)
{
if(data == 0) {
alert("Email doesnt exist");
return false;
}else if (data==1){
alert("The Email is already linked to your location!");
return false;
}else if (data==2){
form.submit();
return true;
}
}
});
}
});
Upvotes: 2