Reputation: 747
I'm working on a js form validation and so far I have this:
// grab form field values
var valid = '';
var name = $('form #name').val();
// perform error checking
if (name = '' || name.length <= 2) {
valid = '<p>Your name' + required +'</p>';
}
How can I validate that the user has chosen one of the options from a dropdown that I have in my form?
Thanks in advance.
Upvotes: 1
Views: 59
Reputation: 1428
if($('select.your-class-here').val() !== '') { //value select
} else { //nothing selected
}
Upvotes: 1