我使用jQuery验证客户端验证,我想忽略任何具有style =“display:none”的元素
$("#myform").validate({ ignore: "?" });
在上述情况下,我的选择器是什么?
解决方法
注意:从版本1.9.0开始,忽略:“: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.