So basically I have a simple POST form that is being validated using Validate library from jquery, and it all works fine, but then I used the tabs function from bootstrap and many other libraries to separate the form into two different tabs. The problem now is that validation happens only to the open (visible) tab, regardless the condition of the other input fields in hidden tabs. Any possible suggestions?
Asked
Active
Viewed 1.2k times
12
-
This question is answered here: http://stackoverflow.com/questions/5643500/jquery-validation-multiple-tabs-validate-one-at-a-time – jtheman Oct 17 '12 at 06:31
-
yes it will only validate your visible field, you can use form wizard for your use – rajesh kakawat Oct 17 '12 at 06:32
-
very helpful question http://stackoverflow.com/questions/8466643 – Hakan Fıstık Nov 30 '16 at 08:56
2 Answers
28
I think your trouble might be that jquery by default will only validate visible fields. So what you need to do is tell jquery to not ignore your hidden fields (other tabs). This can be done as follows:
$("#form1").validate({
ignore: ""
});
By default ignore: ":hidden"
.
See this answer, and this documentation (Options -> Ignore).
3
Please see the accepted answer above, it is really helpful.
Just in case of using unobtrusive validation
, then the accepted answer will not work, and here is the solution.
$("#form1").data("validator").settings.ignore = "";

Community
- 1
- 1

Hakan Fıstık
- 16,800
- 14
- 110
- 131
-
1Thanks, you saved my day. I've been seeing the solution from accepted answer everywhere and was wondering why it's not working for me. cheers! – Pirate Apr 21 '21 at 13:57