如何禁用“渴望”验证完全使用jquery validate?

发布于 2024-08-29 19:05:11 字数 179 浏览 3 评论 0原文

有没有办法使用 jquery.validate 插件禁用“急切”验证?通过脚本中的选项还是作为黑客?一旦表单被验证一次,“急切”验证就会启动 - 之后,无效字段将在焦点退出时进行验证。我想禁用此行为,并将我的表单更改为仅在按下提交按钮时才进行验证。

我也不介意破解验证脚本本身,所以如果这是解决方案所需要的,那么这是可以接受的。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不如归去 2024-09-05 19:05:11

查看 onfocusout 选项。

onfocusout, boolean, default:true

“在模糊时验证元素(复选框/单选按钮除外)。如果未输入任何内容,则跳过所有规则,除非该字段已标记为无效。 ”

大约一半

因此要禁用“急切”验证:

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

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
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文