0

I am using MVC 5 and I have a strange problem with the built in validation:
On my page is a tab-control which shows and hides div's via their display style.
My model has some fields which are decorated with [Required].

If I now leave such a field on tab #1 empty and switch to tab #2 and trigger the validation (e.g. try to submit the form) the field on tab #1 validates to true and if there are no other validation errors on tab #2 the form submits. If I switch back to tab #1 and trigger the validation again without any change otherwise the field correctly fails the validation.

I already tried removing the ignoring of hidden fields via:

$.validator.setDefaults({ ignore: null });

But that did not help either.

I use THIS hooks to do some custom task after the validation and there I see the validation is executed, but really returns the wrong result.

Does someone have an idea how I can fix this?

Christoph Fink
  • 22,727
  • 9
  • 68
  • 113
  • See both [this](http://stackoverflow.com/a/8565769/594235) and [this](http://stackoverflow.com/a/14506637/594235). – Sparky Jul 08 '14 at 18:21
  • @Sparky: Thx - worked, BUT only when NOT inside `$(document).ready(function () { });`. I wonder why I did not find that question even if searching nearly exactly for their title... – Christoph Fink Jul 08 '14 at 18:33

0 Answers0