Reputation: 388
I have a form and into this form, I have nav-tabs from BootStrap. In my ViewModel, I added the data annotations for each item...
My problem is: when the submit button is hit, the validation occours normally on the active tab, but in the other tabs (that are hidden), the validation seems to not work... it only work if i switch to that tab and try to submit the form again, than that tab will be validated or not.
How can i get the data annotations to work on hidden tabs the same way they do in the active tab?
Upvotes: 1
Views: 551
Reputation: 2210
From the jquery Validation Plugin 1.9.0 onwards, the invisible elements are not validated. In the bootstrap nav bar tabs, only active tabs are visible so these are only validated. To enable validation for fields in all tabs you need to change default value of ignore to [], it has default value as hidden. Use the below code to change the default behaviour and call it at onload method or from view.
$.validator.setDefaults({
ignore: []
});
Upvotes: 0