jQuery Validate Required Select
Solution 1:
An easier solution has been outlined here: Validate select box
Make the value be empty and add the required attribute
<select id="select" class="required">
<option value="">Choose an option</option>
<option value="option1">Option1</option>
<option value="option2">Option2</option>
<option value="option3">Option3</option>
</select>
Solution 2:
You can write your own rule!
// add the rule here
$.validator.addMethod("valueNotEquals", function(value, element, arg){
return arg !== value;
}, "Value must not equal arg.");
// configure your validation
$("form").validate({
rules: {
SelectName: { valueNotEquals: "default" }
},
messages: {
SelectName: { valueNotEquals: "Please select an item!" }
}
});
Solution 3:
the most simple solution
just set the value of the first option to empty string value=""
<option value="">Choose...</option>
and jquery validation required
rule will work
Solution 4:
use min rule
set first option value to 0
'selectName':{min:1}