jQuery验证插件-您可以启用“急切"功能吗?从选项验证? [英] Jquery Validation Plugin - can you enable "eager" validation from the options?

查看:87
本文介绍了jQuery验证插件-您可以启用“急切"功能吗?从选项验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个项目上使用Jquery Validation插件.

I'm using the Jquery Validation plugin on a project.

默认情况下,单击提交按钮时,插件会验证输入.该行为是懒惰的",以便对用户不打扰.如果发现错误,验证将变为渴望",并在用户更正有问题的条目时验证输入.

By default, the plugin validates input when the submit button is clicked. The behavior is "lazy" in order to be unobtrusive to the user. If an error is found, the validation then becomes "eager" and validates input as the user corrects the offending entries.

是否有任何方法可以通过选项覆盖初始的懒惰"行为?我在文档中找不到任何解决方案.

Is there any way to override the initial "lazy" behavior through an option? I can't find any solution in the documentation.

示例:

如果您查看此演示,您会发现用户可以浏览表单上留下空白文本框,当用户单击提交"时,这些文本框将无法通过验证.如果用户最初在电子邮件文本框中输入了无效的电子邮件地址,则在单击提交"按钮之前,该地址不会突出显示. 之后,每次按键和模糊事件都会验证输入.那就是我想一开始就激活的东西.

If you look at this demo, you will notice that the user can navigate through the form leaving empty text boxes that will fail validation when the user clicks on submit. If the user initially enters an invalid email address on the email textbox, it is not highlighted until the submit button is clicked. After that, the input is validated on each key press and blur event. That is what I'd like to activate from the start.

我了解插件创建者的设计选择,但是我需要不同的行为.

I understand the design choice of the plugin creator, but I need different behavior.

推荐答案

实际上,我得到的默认行为是对focusoutkeyup事件的验证,我在插件代码中看到它们是默认行为.我必须在插件配置中禁用它们,以便仅在提交时进行验证.也许您应该发布一些代码...我认为情况并不完全清楚.

Actually, the default behavior I get is validation on the focusout and keyup events, which I see in the plugin code as defaults. I have to disable those in the plugin configuration in order to only get validation at submit. Perhaps you should post some of your code... I don't think the situation is completely clear.

这篇关于jQuery验证插件-您可以启用“急切"功能吗?从选项验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆