Reputation: 5933
I am new to Jquery. I am working in a form with 14 fields
First 7 fields are visible and next 7 are toggled on the basis of a button click in a div now in total there are 7 fields which are 'required'. 3 from first 7(visible part) and 4 from toggling div.
The problem is that when the toggling div is visible JQuery's validation plugin shows the required message if I miss any of the 7 fields but the same plugin just checks the validation of only 3 fields (which are in visible part of the form) when the div is hidden.
how to make make the validation of full form even when the part of the form is hidden
Now if I delete the value of text box Address 1 and hides the Address Part and click SAVE it will not prompt for required thing for Address 1 even when I kept it 'required'
Upvotes: 2
Views: 5851
Reputation: 15210
The possible reason can be that there is ignore: ':hidden'
line in jquery.validate.unobtrusive.js
file. Just remove that line.
After 1.9.0 version it was default behaviour. If the line doesn't exists in file(I'm not sure) you can fix that manually by adding
$.validator.setDefaults({ ignore: [] });
As you can see here
Another change should make the setup of forms with hidden elements easier, these are now ignored by default (option “ignore” has “:hidden” now as default). In theory, this could break an existing setup. In the unlikely case that it actually does, you can fix it by setting the ignore-option to “[]” (square brackets without the quotes).
Upvotes: 11