1

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.

2 Answers 2

3
$('select.foo').val(); 

check this

http://api.jquery.com/val/

Sign up to request clarification or add additional context in comments.

Comments

1
if($('select.your-class-here').val() !== '') { //value select

} else { //nothing selected

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.