Combo check box, user must check max 3 options


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++) {
return false;
return true;