Skip to content

Instantly share code, notes, and snippets.

@antoniorosado
Created July 19, 2011 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoniorosado/1092919 to your computer and use it in GitHub Desktop.
Save antoniorosado/1092919 to your computer and use it in GitHub Desktop.
//Add a method to the validator that checks to see if at least one of the
// three checkboxes specified are checked.
jQuery.validator.addMethod('atLeastOneChecked', function(value, element) {
var checkedCount = 0;
if (jQuery('#checkBoxListOne').is(':checked')){
checkedCount += 1;
}
if (jQuery('#checkBoxListTwo').is(':checked')){
checkedCount += 1;
}
if (jQuery('#checkBoxListThree').is(':checked')){
checkedCount += 1;
}
return checkedCount > 0;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment