开发者

Custom submit function after jQuery Validation

How woul开发者_开发问答d I add a custom submit function to a form to prevent it's normal action but so that it only runs after being validated by the jQuery Validation plugin?


You can use the submitHandler option of .validate(), like this:

$("form").validate({
  submitHandler: function(form) {
    //this runs when the form validated successfully
    form.submit(); //submit it the form
  }
});

There's also an invalidHandler if you want to run something when it doesn't pass validation.


In the event handler return true to proceed and return false to stop.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜