[英]jquery validate plugin - ignore not visible inputs, but include hidden inputs with class
I have a form that changes the inputs displayed on screen depending on a drop down list value. 我有一个表格,可以根据下拉列表值更改屏幕上显示的输入。
This ignore definition works fine and does not validate any inputs with ignore class and that are not visible . 此忽略定义可以正常工作,并且不使用ignore类验证任何不可见的输入 。
ignore: ":not(:visible), .ignore",
But the problem now is when I want to validate a few hidden
inputs with class ' validate ' , so I changed this to: 但是现在的问题是,当我想使用类validate来验证一些
hidden
输入时,因此将其更改为:
ignore: ":hidden:not(.validate), :not(:visible), .ignore",
But the :not(:visible) blocks it. 但是:not(:visible)阻止了它。 How to apply these 2 rules together so I will be able to ignore not visible inputs and validate hidden inputs with 'validate' class?
如何将这两个规则一起应用,以便我可以忽略不可见的输入并使用“ validate”类验证隐藏的输入?
If you want to ignore all hidden elements, but still validate any hidden element with the .validate
class, it's simply the default :hidden
selector with the .validate
class excluded... 如果您想忽略所有隐藏元素,但仍使用
.validate
类验证任何隐藏元素,则它是默认的:hidden
选择器,但不包括.validate
类...
ignore: ":hidden:not(.validate)"
DEMO : jsfiddle.net/0avft8ou/ 演示 : jsfiddle.net/0avft8ou/
You probably don't need an .ignore
class because the plugin will automatically ignore any hidden element. 您可能不需要
.ignore
类,因为该插件将自动忽略任何隐藏的元素。
尝试将第一个规则更改为
ignore: ":not(:visible), :not(:hidden), .ignore"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.