Using jQuery , you can do something like:
var MAX_CREDITS = 50;
$("input[type=checkbox]").change(function (){
var totalCredits = 0;
$("input[type=checkbox]").each(function (){
});
if(totalCredits > MAX_CREDITS){
$(this).removeAttr("checked");
}
});
If you've never used jQuery before, it certainly looks like a pain for your eyes; but as you can see, it is very powerful, and your problem can be solved in a few lines. I would recommend you to study it and try to try;)
source
share