I would like to run a function if my form has completely validated according to my defined rules (Not shown below).
The below code doesn't work as I would like it to, most certainly depending on the fact that the success
function is called on a per-input basis and not globally for the complete form .
Are there any workarounds to get a global success callback that runs when the complete form validates properly?
$("#myForm").validate({
success: function(label) {
if ($("#myForm").valid()) {
runMyFunction();
}
},
rules: {
//...
}
});
$("#myForm").validate({
rules: {
//...
},
success: function(label) {
},
submitHandler: function(e) {
e.preventDefault();
runMyFunction();
}
});
REF: http://docs.jquery.com/Plugins/Validation/validate#toptions
you dont have to do
if ($("#myForm").valid()) {
runMyFunction();
}
the success
callback is called only when the from is validated just runMyFunction()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With