0
I use toogle bootstrap from this example: http://www.bootstraptoggle.com/
I have 4 checkbox, one of them must have true.
How to do this with jquery validate ?
Follows code:
<label for="checkbox[]" generated="true"></label>
<label class="checkbox-inline">
<input id="checkbox1" class="checkbox[]" type="checkbox" data-onstyle = "success" data-offstyle = "danger" data-on = "Sim" data-off = "Não" data-size = "mini">
</label>
<label class="checkbox-inline">
<input id="checkbox2" class="checkbox[]" type="checkbox" data-onstyle = "success" data-offstyle = "danger" data-on = "Sim" data-off = "Não" data-size = "mini">
</label>
<label class="checkbox-inline">
<input id="checkbox3" class="checkbox[]" type="checkbox" data-onstyle = "success" data-offstyle = "danger" data-on = "Sim" data-off = "Não" data-size = "mini">
</label>
<label class="checkbox-inline">
<input id="checkbox4" class="checkbox[]" type="checkbox" data-onstyle = "success" data-offstyle = "danger" data-on = "Sim" data-off = "Não" data-size = "mini">
</label>
Javasxcript:
$(document).ready(function () {
$("#myform").validate({
ignore: ":hidden",
rules: {
"checkbox[]": { required: true, minlength: 1 }
},
messages: {
"checkbox[]": "<span style=\"color: #a94442;\">Uma das opções abaixo devem ser marcada *</span>"
},
....
....
....
}
}
Nothing happens. I don’t know what I’m doing wrong.
I think it’s the name of the class, try to change, not to be with "[ ]"
– Miguel
Yeah, try it, Matheus
– Miguel
@Miguel, it didn’t work
– Matheus Miranda