<form>
<input type='text' value='a' name='t1'>
<input type='checkbox' name='c1'>
<input type='checkbox' name='c2'>
<input type='checkbox' name='c3'>
<input type='checkbox' name='c4'>
<input type='button' onclick='test();'>
</form>
<script>
function test(){
var c=0;
inputs = document.getElementsByTagName('input');
for(i=0;i<inputs.length;i++){
if(inputs[i].type=='checkbox' && inputs[i].checked){
c++;
break;
}
else
continue;
}
if( c==0 ){
alert('error');
return false;
}
}
</script>
<input type='text' value='a' name='t1'>
<input type='checkbox' name='c1'>
<input type='checkbox' name='c2'>
<input type='checkbox' name='c3'>
<input type='checkbox' name='c4'>
<input type='button' onclick='test();'>
</form>
<script>
function test(){
var c=0;
inputs = document.getElementsByTagName('input');
for(i=0;i<inputs.length;i++){
if(inputs[i].type=='checkbox' && inputs[i].checked){
c++;
break;
}
else
continue;
}
if( c==0 ){
alert('error');
return false;
}
}
</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货