Created
December 6, 2012 00:58
-
-
Save jklance/4220990 to your computer and use it in GitHub Desktop.
Limit HTML checkbox selections
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
// Limit the number of checkboxes that can be selected at one time | |
var checkboxLimit = 3; | |
var questionTolimit = 'q3'; | |
$("input[type=checkbox][name="+questionTolimit+"]").click(function() { | |
var checkTest = $("input[type=checkbox][name="+questionTolimit+"]:checked").length >= checkboxLimit; | |
$("input[type=checkbox][name="+questionTolimit+"]").not(":checked").attr("disabled",checkTest); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment