views:

35

answers:

2

Hi,

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;
    }
}
});
+1  A: 

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

rules: { 
    dest_var: { 
        required: true,
        rangelength:[2,3]
    }
} 
Pat
I doesn't work... thanks a lot!
Omega
+2  A: 

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();
digitalFresh
it works even if with []...thanks a lot!
Omega