jQuery 验证插件全局关闭文本标签?
我目前正在使用这段代码来循环遍历具有特定类的所有输入,并将消息设置为空字符串,但想知道是否有一种更优雅的方法来关闭所有“next-to-the-input”错误消息。已经尝试使用包装器和容器的组合以及分组消息,但默认值始终存在,并在这些东西试图隐藏消息时显示消息。罪魁祸首是“display: inline”IIRC 的内联样式。
$("input.baseAllocationAmount").each(function(idx, elm){
validationMessages[$(elm).attr("name")] = "";
});
var formValidationOptions = {
wrapper: "span",
messages: validationMessages
});
I'm currently using this bit of code to loop through all inputs with a certain class and set the message to an empty string, but was wondering if there's a more elegant way to turn off all "next-to-the-input" error messages. Been through a few tries using combinations of wrapper and container and grouping messages, but the defaults are always there and show messages when those things try to hide them. Main culprit is inline style of "display: inline" IIRC.
$("input.baseAllocationAmount").each(function(idx, elm){
validationMessages[$(elm).attr("name")] = "";
});
var formValidationOptions = {
wrapper: "span",
messages: validationMessages
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可以解决问题:
This does the trick:
您是否尝试过使用一些插件选项?
看起来你可以使用
showErrors
,或者可能errorClass
或have you tried playing around with some of the plugin's options?
looks like you could use
showErrors
, or possiblyerrorClass
or