[jQuery] validate - require validation in multiple varying instances
I'm using the jquery validator supplied here:
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
The form I made has six different sections corresponding to six
different sets of information being entered. For clarity, I should
mention that this is an RSVP form, and the user is able to RSVP for up
to six people. The sections and input fields are numbered accordingly:
section1 firstname1 lastname1, section2 firstname2 lastname2...
section6 firstname6 lastname6
To indicate how many people are being entered, there is a radio
button, and the user is required to select a number 1 through 6. (i.e.
if the number "3" is selected, the user is RSVPing for 3 people, and
thus must enter all required information for person 1, person 2, and
person 3.)
The problem is that I don't know how to require validation on a
certain field if one of several conditions are met.
This works:
'firstname2': {
required: "#guests_two:checked",
},
This does not:
'firstname2': {
required: "#guests_one:checked",
required: "#guests_two:checked",
},
This does not:
'firstname2': {
required: "#guests_one:checked" || "#guests_two:checked",
},
This does not:
'firstname2': {
required: "#guests_one:checked"
},
'firstname2': {
required: "#guests_two:checked"
},
Any help would be greatly appreciated!