开发者

How to disable the onclick function of the form until validation is complete?

开发者 https://www.devze.com 2022-12-16 21:40 出处:网络
I am using the jQuery Validation plugin I have the following code in an onClick function of my form submit button.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消