I have three fields in a form which is using jQuery validate.js:
<input type="text" id="StartDate" name="StartDate"><br />
<input type="text" id="EndDate" name="EndDate"><br />
<label for="AllDate"><input type="checkbox" name="AllDate" id="AllDate">All Dates</label>
I need #StartDate to be required on submit UNLESS #AllDate is checked. If #AllDate is checked, #StartDate is NOT required
Failed attempt(s):
rules: {
StartDate: {
required: {
depends: function(element) {
return (! $("input[type='checkbox']:checked"))
}
}
}
}
I have had no luck creating a custom validation rule either. I am looking for a better way, one that works!