多选复选框非空验证
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>check box</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<Script Language="JavaScript">
function check(){
var textbox=document.getElementsByName('test');
for(i=0;i<textbox.length;i++){
if(!textbox[i].checked){
if(i==textbox.length-1){
return alert('请选择一个!');
}
}else{
break;
}
}
}
</Script>
</head>
<body>
<input type="checkbox" name="test" value="1" />
<input type="checkbox" name="test" value="2" />
<input type="checkbox" name="test" value="3" />
<input type="checkbox" name="test" value="4" />
<input type="checkbox" name="test" value="5" />
<input type="button" name="submit" οnclick="check()" value="提交" />
</body>
</html>