I have two input checkboxes as below:
<input type="checkbox" value="1" name="items[test1]" id="items_test1">
<input type="checkbox" value="1" name="items[test2]" id="items_test2">
I want atleast one of them to be checked. For that I added jquery validate plugin code as below:
$.validator.addMethod("checkTest", function(value) {
return false; // return false just to check whether it triggers error
}, 'Please check atleast one');
$(document).ready(function() {
$("form").validate({
groups: {
checkTest: 'items[test1] items[test2]'
},
errorPlacement: function(error, element) {
console.log(error);
});
});
This check is nevered triggered. What am I doing wrong?