I\'m trying to use the jQuery Validate plugin to validate a dropdown. It validates the rest of my form correctly. But it doesn\'t work on the dropdown.
Here is my jQue
If you just want to make a select element required, you would not use depends: because it does not "depend" on another element. In your usage, the depends property is simply toggling the required rule. The problem here is not the required rule... it does not need to be toggled. The problem is that the required rule will not work when all options already contain a value, since required will always be satisfied.
Simply use value="" for the default option, and then set your rules just like any other element.
jsFiddle DEMO
HTML:
jQuery:
$(document).ready(function() {
$('#campaignForm').validate({
rules: {
html_url: {
required: true
}
},
messages: {
html_url: {
required: 'Please select a template'
}
}
});
});