我正在使用 jQuery validate 进行客户端验证,并且我想忽略任何具有 style="display: none"
$("#myform").validate({
ignore: "?"
});
在上述情况下我的选择器是什么?
最佳答案
注意:从版本 1.9.0 开始,ignore: ":hidden"
是默认选项,因此不必再显式设置。
使用:hidden
:
Elements can be considered hidden for several reasons:
- They have a display value of none.
- They are form elements with type="hidden".
- Their width and height are explicitly set to 0.
- An ancestor element is hidden, so the element is not shown on the page.
$("#myform").validate({
ignore: ":hidden"
});
<小时/>
更新:为了完整性,来自 plugin's documentation :
ignore
Elements to ignore when validating, simply filtering them out. jQuery's not-method is used, therefore everything that is accepted bynot()
can be passed as this option. Inputs of type submit and reset are always ignored, so are disabled elements.
关于jQuery 验证忽略带有样式的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2623514/