How do I disable “eager” validation entirely using jquery validate?

左心房为你撑大大i 提交于 2020-01-02 02:15:18

问题


Is there a way to disable "eager" validation using the jquery.validate plugin? Either through an option in the script or as a hack? "Eager" validation kicks in once the form has been validated once - after that, invalid fields are validated onfocusout. I want to disable this behavior, and change my forms to only be validated when the submit button is pressed.

I don't mind hacking through the validate script itself also, so if that's what the solution requires that's acceptable.


回答1:


Check out the onfocusout option.

onfocusout, boolean, default:true

"Validate elements (except checkboxes/radio buttons) on blur. If nothing is entered, all rules are skipped, except when the field was already marked as invalid."

About halfway down.

So to disable "eager" validation:

$(".selector").validate({
  onfocusout: false
});


来源:https://stackoverflow.com/questions/2706778/how-do-i-disable-eager-validation-entirely-using-jquery-validate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!