I am running this form check when the form is submitted:
if((formData[4].value == 1 || formData[4].value == 2) && !formData[2].value) {
alert(\'
A return
in the callback returns from that callback, not the parent function like you want...however you can get the effect you want, like this:
if((formData[4].value == 1 || formData[4].value == 2) && !formData[2].value) {
alert('Please fill out the key field');
return false;
} else {
$.ajax({
url: "/ajax/key_check.php",
cache: false,
data: "key=" + formData[4].value,
dataType: "html",
success: function(data) {
if(data == 1) {
alert('Key already exists');
} else {
$("#someForm")[0].submit();
}
}
});
return false;
}
What this does is never submit directly, but if the check is ok, calls the *native .submit() method, submitting the form and not running this handler again.