xVal 验证失败时的事件?
我有一个注册表单,利用 xVal 来处理表单上的所有验证。它工作得很好,但有一个例外:用户没有得到反馈,因为页面上的另一个元素(告诉用户他们的用户名将是他们的电子邮件地址的提示)绘制在 span 元素的顶部,xVal 在注意到时会吐出一个问题。
如果我有办法检测 xVal 的电子邮件字段何时出现问题,我可以切换该工具提示的可见性并继续前进,但我不知道该怎么做。我知道 xVal 在底层使用了 jquery.validate.js;有什么活动或事情我可以参与来做这件事吗?
I have a registration form leveraging xVal to handle all validation on the form. It works really well, with one exception: the user doesn't get feedback because another element on the page (a tip telling the user that their username will be their email address) draws on top of the span element xVal spits out when it notices a problem.
If I had a way to detect when xVal has a problem with the email field, I could just toggle the visibility of that tooltip and be on my way, but I'm not sure how to do so. I know that xVal uses jquery.validate.js under the hood; is there an event or something I could tie into to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在不真正了解 xVal 以及如何/是否可以轻松设置 jQuery 验证的自定义选项的情况下,如果仅使用 jQuery 验证插件,您将执行以下操作。
您可以连接
showErrors
回调和/或invalidHandler
回调检查 jQuery 验证插件选项文档 了解更多信息
,例如像这样的东西应该可以工作(但要知道错误不再存在是比较棘手的)
Without really knowing xVal and how/if you can easily set custom options for the jQuery validation you would do the following if just using the jQuery Validation plugin.
You would hook up the
showErrors
callback and/or theinvalidHandler
callbackCheck the jQuery Validation Plugin options documentation for more info
e.g. something like this should work (but it's trickier to know the error is no longer there)