Skip to content

Instantly share code, notes, and snippets.

@ReeMii
Created October 4, 2013 10:17
Show Gist options
  • Save ReeMii/6823839 to your computer and use it in GitHub Desktop.
Save ReeMii/6823839 to your computer and use it in GitHub Desktop.
limit checkboxes
function limitCheckboxes(control, max) {
$(control).click(function () {
if(!$(this).is(':checked')) {
return true;
} else if($(control).filter(":checked").length>max) {
return false;
}
});
}
//sample usage
$(document).ready(function () {
LimitCheckboxes('.checkbox input', 3);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment