6

I need to validate hidden fields, so I have this below (validate hidden fields)

$.validator.setDefaults({ ignore: [] });

I would like to ignore a certain class as well, but I'm not sure of the syntax to get both.

$.validator.setDefaults({ ignore: "[], .ignoreThisClass" });

This obviously does not work but how can I specify to both validate hidden and ignore my class?

Community
  • 1
  • 1
aw04
  • 10,857
  • 10
  • 56
  • 89

3 Answers3

13

Add your class to the array instead.

$.validator.setDefaults({ ignore: [".ignoreThisClass"] });

It's an array of jquery selectors. If the element matches the selector, it is ignored. By default it is [":hidden"] which is why making it [] makes it allow hidden elements.

Kevin B
  • 94,570
  • 16
  • 163
  • 180
-1
$.validator.setDefaults({
ignore: ".ignoreThisClass"
});
Murali Murugesan
  • 22,423
  • 17
  • 73
  • 120
-1

Try putting in your .ignoreThisClass class the property.

visibility: hidden;

I believe it will work

Hunter Turner
  • 6,804
  • 11
  • 41
  • 56