复选框checkBox最多选择5个的判断代码
[ 2009-12-15 16:41:21 | 作者: admin ]
<script language="JavaScript1.2">
//52News.com
function CheckSel()
{
var objs = document.formVote.ids;
var checkedCount = 0;
for(var i = 0; i < objs.length; i++) {
if(objs[i].checked)
checkedCount++;
}
if (checkedCount > 5) {
alert("最多选5个");
return false;
}
}
</script>
//52News.com
function CheckSel()
{
var objs = document.formVote.ids;
var checkedCount = 0;
for(var i = 0; i < objs.length; i++) {
if(objs[i].checked)
checkedCount++;
}
if (checkedCount > 5) {
alert("最多选5个");
return false;
}
}
</script>
使用方法:
<input name="id" type="checkbox" value="<%=rs("id")%>" onclick="return CheckSel()" />
1