Combo check box, user must check max 3 options


#1

I want the user to be able to select max 3 options on my combo check box. If he has 3 he wont be able to check a 4 one unless he unchecks first one. I tried this code but with no luck.

combo.attachEvent(“onBeforeCheck”, function (value, newState) {
var checked_arr = combo.getChecked();
var arr_text = new Array();
var count = 0;
for (var i = 0; i < checked_arr.length; i++) {
arr_text.push(combo.getOption(checked_arr[i]).text);
count++;
}
if(count>=3){
return false;
}else
return true;

});