jquery validate - 检查哪个规则未满足
我有一个包含多个字段并使用 jQuery 验证插件的表单。我的输入有几个规则:
{
required : "#somecheckbox:not(:checked)",
regex : "\d{10}",
maxlength : 10,
remote : [object Object],
__dummy__ : true
}
我想知道的是,如何检查哪些规则未得到满足(或者某些特定规则是否有效)。我知道这是可能的,因为远程验证不会触发 ajax 请求,直到其他请求已满,但我无法在 jquery.validate.js 中找到它是如何完成的。
I have a form with several fields and using jQuery validation plugin. My input has several rules:
{
required : "#somecheckbox:not(:checked)",
regex : "\d{10}",
maxlength : 10,
remote : [object Object],
__dummy__ : true
}
What I want to know is, how I can check which of these rules are not fulfilled (or is some specific rule valid or not). I know that this is possible as remote validation does not fire ajax requests until others are fullfiled, but I cannot find in jquery.validate.js how it is done.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经通过检查 jQuery 验证插件的源代码弄清楚了如何做到这一点,所以我制作了自己的函数来利用它:
用法很简单:
示例结果是:
从这个对象很容易看出哪些规则不满足。
I have figured out how to do this by examining source of jQuery validate plugin, so I made my own function to tap into it:
Usage is simple:
And sample result is:
From this object it is easy to see what rules are not satisfied.