jQuery验证使用样式忽略元素

前端之家收集整理的这篇文章主要介绍了jQuery验证使用样式忽略元素前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用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 by not() can be passed as this option. Inputs of type submit and reset are always ignored,so are disabled elements.

原文链接:/jquery/182557.html

猜你在找的jQuery相关文章