本文介绍了jQuery验证-隐藏错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用jQuery Validation插件,并希望禁用它创建的or或元素/容器以显示错误"message".
I'm using the jQuery Validation plugin and want to disable the or element/container it creates to display the error 'message'.
基本上,我希望有错误的输入元素具有错误类,但不要创建包含错误消息的其他元素.
Basically, I want the input element with the error to have the error class but NOT create an additional element containing the error message.
这可能吗?
我刚刚想到了CSS解决方法,但这并不能真正解决仍在创建元素的事实吗?
I have just thought of a CSS workaround, but it doesn't really fix the fact that the element is still being created?
<style>
label.simpleValidationError {display: none !important; }
</style>
推荐答案
将Validator errorPlacement选项与一个空函数一起使用:
Use the Validator errorPlacement option with an empty function:
$("selector").validate({ errorPlacement: function(error, element) {} });
这有效地将错误消息放在任何地方.
This effectively places the error messages nowhere.
这篇关于jQuery验证-隐藏错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!