I'm using iCheck to style checkboxes and I'm having trouble using this along side validation. Basically I need to allow 3 checkboxes to be checked at a time and prevent further boxes from being checked.
I've tried using this:
$("#modal1").on("change", function()
{
var limit = 3,
checkboxes = $(this).find("input:checkbox"),
valid = checkboxes.filter(":checked").length >= limit;
checkboxes.not(":checked").attr("disabled", valid);
$('input').iCheck('update');
});
It works without iCheck as seen below, but I can't get iCheck to update.
I up adding
.on("ifToggled"
plus SpaceDog's code, which solved the problem.It looks like the iCheck update method isn't seeing the change to the disabled attribute. You could try the native iCheck method for disabling a checkbox:
make some changes in code