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?