You can see the effect after selecting 3
]<script>
function disableCheckBox() {
var obj=document.getElementsByTagName("input")
for(var i=0;i<obj.length;i++)
{
if ( !obj[i].checked )
obj[i].disabled = true;
}
}
function ableCheckBox() {
var obj=document.getElementsByTagName("input")
for(var i=0;i<obj.length;i++)
obj[i].disabled = false;
}
function check()
{
var obj=document.getElementsByTagName("input")
var sun=0;
for(var i=0;i<obj.length;i++)
{
if(obj[i].type=="checkbox" &&
obj[i].checked)
sun++;
if( sun< 3 )
{
ableCheckBox();
//break;
}
else if(sun == 3 )
{
disableCheckBox();
event.srcElement.checked=true;
break;
}
else if(sun > 3 )
{
event.srcElement.checked=false;
break;
}
}
}
</script>