Possible Duplicate:
JQuery validation-select required if checkbox checked
I’m validating a form with jQuery Validation. I’m trying to come up with a rule that will validate fields as required if a field in a particular set of fields is filled:
<form id="donate-form">
<input type="text" name="full_name" required="required" /><br />
<input type="text" name="address1" /><br />
<input type="text" name="address2" /><br />
<input type="text" name="city" /><br />
<select name="state">
<option value="">- State -</option>
<option value="va">Virginia</option>
<option value="md">Maryland</option>
</select><br />
<input type="text" name="zip" />
<input type="submit" name="submit" />
</form>
All address fields are optional unless someone fills out address1, city, state, or zip, then they should all be required.
Example
Using
depends, fill in your requirements.You should change the selectors to something more specific to fit your needs. ie not
$('form')