简体   繁体   中英

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: ":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:

ignore: ":hidden:not(.validate), :not(:visible), .ignore",

But the :not(:visible) blocks it. How to apply these 2 rules together so I will be able to ignore not visible inputs and validate hidden inputs with 'validate' class?

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...

ignore: ":hidden:not(.validate)"

DEMO : jsfiddle.net/0avft8ou/

You probably don't need an .ignore class because the plugin will automatically ignore any hidden element.

尝试将第一个规则更改为

ignore: ":not(:visible), :not(:hidden), .ignore"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM