I have a select like this:
<form action="" id="form">
<select name="unidadeNegocio[]" id="unidadeNegocio" multiple="multiple" >
<option> A </option>
<option> B </option>
<option> C </option>
</select>
</form>
I allow this select
enabled to select more than one option with multiselect.js like this:
$(document).ready(function(){
$('#unidadeNegocio').multiselect();
});
I try to validate if at least one select option was selected with the Validate (plugin to validate inputs) like this:
$('#form').validate({
rules: {
"unidadeNegocio[]": {
required: true,
minlength: 1
},
messages: {
"unidadeNegocio[]": {
required: 'Por favor, selecione pelo menos um'
}
}
}
})
The problem is that even though I do not select anything in the select, the form is submitted, it is not validated.