I have two inputs the must be validate on submit.
I’m trying this:
$("#phase1_form").submit(function(e){
var result1 = $("#phase1_responsVibleByFirstSignOff").isValid();
var result2 = $("#phase1_responsibleBySecondSignOff").isValid();
if ((result1
&& result2
))
{
return true;
}
});
But the “isValid” function is not so fast and the form is submitted.
I though that maybe I could use the “preventDefault” method, but I have no idea how to “cancel” the effect of this method after the “isValid” function returns some result.
Thanks
It’s not about the speed of the
isValidfunction, the submit will definitely wait for the result. The problem is that you only returntrueorundefined, but you need to returnfalseto stop the form from submitting: