How to disable the onclick function of the form until validation is complete?
I am using the jQuery Validation plugin
I have the following code in an onClick function of my form submit button.
onClick = "parent.$.fn.fancybox.close();parent.location.reload();"
When the form detects a field is not filled in, it successfully halts submission of开发者_开发百科 the form, however the onClick
event still fires.
Is there a way to get this event to also halt firing when this occurs?
Use the submit handler function with the validation plugin instead of an onclick:
$("#myform").validate({
submitHandler: function(form) {
parent.$.fn.fancybox.close();
parent.location.reload();
form.submit();
}
});
The submitHandler gets triggered after a successful validation of the form.
精彩评论