1

I have this multiple select:

<select id="sel_dest" name="dest_var[]" multiple disabled="disabled" size="10">
<option value="" selected>Destinatario</option>
<option value="1"> .........
</select>

how can i validate (required field) this select with jquery validation plugin?

this code doesn't work:

$("#register_form").validate({
rules: {
    dest_var: {
        required: true;
    }
}
});

3 Answers 3

3

Simply use a required class for the select tag.(and remove the [] in the id)

<select id="sel_dest" name="dest_var" class="required" multiple disabled="disabled" size="10">
<option value="" selected>Destinatario</option>
<option value="1"> .........
</select>

script:

$("#register_form").validate();
Sign up to request clarification or add additional context in comments.

Comments

2

"dest_var[]" : {required: true}

Comments

1

You can see how to do it on the this example page.

rules: { 
    dest_var: { 
        required: true,
        rangelength:[2,3]
    }
} 

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.