日期:2014-05-16  浏览次数:20379 次

怎么控制复选框必须选中多少个才能提交

怎么控制复选框必须选中多少个才能提交?

高手指点。

------解决方案--------------------
<script>
function check()
{
o = document.getElementsByTagName( "input ");
count = 0;
for(c=0; c <o.length; c++)
{
if(o[c].type== "checkbox " && o[c].checked) count++;
}
if(count < 2)
{
alert( "少于10 ");
return false;
}
}
</script>
<form onsubmit= "return check() ">
<input type= "checkbox " name= "a " value= "1 "> 1
<input type= "checkbox " name= "b " value= "2 "> 2
<input type= "checkbox " name= "c " value= "3 "> 3
<input type= "submit ">
</form>