I can make popovers appear using bootstrap easily enough, and I can also do validations using the standard jQuery validation plugin or the jQuery validation engine, but I can't figure out how to feed one into the other.

I think what I need is some hook which is called by the validator when it wants to display a notification, give it a closure that passes the message and the target element to a popover. This seems like a kind of dependency injection.

理论上一切都很好,但是我就是不知道那个钩子在哪里,或者即使在任何一个验证引擎中都存在一个钩子.当我想要的只是错误类型(我甚至不一定需要消息文本)和与之相关的元素时,它们似乎都致力于用各种精心设计的放置、包装、样式选项来显示通知.我找到了整个表单的挂钩,而不是单个通知.

我更喜欢使用类来定义规则的验证系统,因为它们可以很好地处理动态创建的表单.

Anyone have a solution or a better idea?

推荐答案

Take a look at the highlight and showErrors jQuery Validator options, these will let you hook in your own custom error highlights that trigger Bootstrap popovers.

Jquery相关问答推荐

TinyMCE不保存区块报价

try 使用jQuery AJAX将参数传递给http Post方法时出现未知错误

Visual Studio - 将文本粘贴到 cshtml 中会删除文本

我正在try 使用 Jquery 打开与帖子相关的特定 comments

JQuery:$.get 不是函数

哪个 JQuery Select 器会排除与给定 Select 器匹配的父项的项目?

jQuery找到最近的匹配元素

在 JSON 对象上使用 jQuery 的 find()

如何将 JavaScript 对象编码为 JSON?

jQuery - 向下滚动时缩小的粘性标题

标识符 (id) 是否有通配符 Select 器?

如何使用 jQuery 搜索 JSON 树

JavaScript 吸管(告诉鼠标光标下像素的 colored颜色 )

如何立即启动 setInterval 循环?

获取跨域 iframe 的 DOM 内容

为不同的 node 类型配置jstree右键上下文菜单

与 C# HashSet 等效的 JavaScript 是什么?

如何在纯 JavaScript 中模拟鼠标悬停以激活 CSS:悬停?

jQuery empty() 与 remove()

jquery $(window).height() 正在返回文档高度