Reputation: 916
So I have a fairly large form with two different sections. Both sections start off as hidden:
<fieldset class="section1" style="display:none">
//...input fields
</fieldset>
<fieldset class="section2" style="display:none">
//...input fields
</fieldset>
The sections are shown depending on which radio button the user selects. This all works great until I get to validation. How could I go about validating the form using the jQuery/Validation plugin but have it only validate the section that is showing?
Note: There are other sections that are always shown so I'd rather not have two separate forms.
Upvotes: 0
Views: 213
Reputation: 1039298
You could ignore
validation rules for elements inside the hidden section of your form:
$('#myForm').validate({
ignore: 'fieldset:hidden :input',
...
});
Upvotes: 5