Validate select box
Just add a class of required to the select
<select id="select" class="required">
For starters, you can "disable" the option from being selected accidentally by users:
<option value="" disabled="disabled">Choose an option</option>
Then, inside your JavaScript event (doesn't matter whether it is jQuery or JavaScript), for your form to validate whether it is set, do:
select = document.getElementById('select'); // or in jQuery use: select = this;
if (select.value) {
// value is set to a valid option, so submit form
return true;
}
return false;
Or something to that effect.
I don't know how was the plugin the time the question was asked (2009), but I faced the same problem today and solved it this way:
-
Give your select tag a name attribute. For example in this case
<select name="myselect">
-
Instead of working with the attribute value="default" in the tag option, disable the default option as suggested by Jeremy Visser or set value=""
<option disabled="disabled">Choose...</option>
or
<option value="">Choose...</option>
-
Set the plugin validation rule
$( "#YOUR_FORM_ID" ).validate({ rules: { myselect: { required: true } } });
or
<select name="myselect" class="required">
Obs: redsquare's solution works only if you have just one select in your form. If you want his solution to work with more than one select add a name attribute to your select.
Hope it helps! :)