I want to use the jQuery.validate() plugin to check that the user has chosen an option from 3 dropdown lists – day, month and year for their DOB. I don’t need to validate the actual date, just as long as they choose something. I just want the one validation error message to be displayed to read “Please provide your date of birth”.
You can imagine what the markup looks like, but here it is anyway:
<div class="dropdown">
<select id="day" class="styled" name="day">
<option value="">--</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
[ etc... ]
</select>
</div>
<div class="dropdown">
<select id="month" class="styled" name="month">
<option value="">--</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
[ etc... ]
</select>
</div>
<div class="dropdown">
<select id="year" class="styled" name="year">
<option value="">--</option>
<option value="1993">1993</option>
<option value="1992">1992</option>
<option value="1991">1991</option>
<option value="1990">1990</option>
[ etc... ]
</select>
</div>
Not strictly JQuery, but i did a function in JavaScript, which configures the form drop downs to suit the number of days for a given month/year combination, it expects the drop downs to have the first entry as a description
The Function