I use bootstrap toogle for this example: link
I have 4 checkboxes, one of them should be true.
How to do this with jquery validate?
Follow the code below:
<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 do not know what I'm doing wrong.