1

I have found this question but it was written in 2009, presumably since then they have decided to ignore hidden fields by default...anyone know how I can validate my hidden fields?

I have a custom invalidHandler to deal with the result and was seeing some strange behaviour, I now realise this is because some of my fields are hidden (using display:none). I have a tabbed form, hence some elements being hidden FYI.

Thanks in advance.

2
  • a small hack would be to call the validation before the tab change, if there are errors don't let the user change the tab. Commented Jan 4, 2012 at 10:17
  • Did you try $("#myform").validate({ ignore: ":hidden" }); Commented Jan 4, 2012 at 10:17

1 Answer 1

4

Found the answer...

I started looking at the validator plugin code and came across this:

$.extend($.validator, {
defaults: {
messages: {},
groups: {},
rules: {},
errorClass: "error",
validClass: "valid",
errorElement: "label",
focusInvalid: true,
errorContainer: $( [] ),
errorLabelContainer: $( [] ),
onsubmit: true,
ignore: ":hidden", 
...

So I set the option 'ignore' to an empty string and it works. I guess the documentation should be updated because it doesn't state that there is a default for ignore.

Thanks anyway.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.