<input type=checkbox><input type=checkbox>
<input type=checkbox><input type=checkbox>
<script>
var sw=document.all.tags("input"),chk=false
for(var i=0;i<sw.length;i++)
{
if (sw[i].checked==true)
{
chk=true
}
}
if(!chk)alert("未选择")
</script>

解决方案 »

  1.   

    下面的例子可解决这个问题:<html>
    <head>
    <title></title>
    <script id="clientEventHandlersJS" language="javascript">
    <!--function Button1_onclick() {
    var ObjectCount=0
    var j=0ObjectCount=document.all.length;
    var ifcheck=0
    for (i=1;i<ObjectCount;i++)
      {
      if (document.all.item(i).tagName=="INPUT")
        if (document.all.item(i).type=="checkbox")
          if (document.all.item(i).checked)
             ifcheck=1;
      }
      if (ifcheck==0 )
       alert("请选择一个选项!");
    }//-->
    </script>
    </head>
    <body MS_POSITIONING="GridLayout">
    <INPUT id="Checkbox1" type="checkbox" name="Checkbox1" >hello1<br>
    <INPUT id="Checkbox2" type="checkbox" name="Checkbox2">hello2<br>
    <INPUT id="Checkbox3" type="checkbox" name="Checkbox3">hello3<br>
    <INPUT id="Button1" type="button" value="Button" name="Button1" language="javascript" onclick="return Button1_onclick()">
    </body>
    </html>
      

  2.   

    checked
    代码自己写,我困了..........
      

  3.   

    我一直在用的一个函数。// 是否至少选择了一项. 
    function isSelectedOne(form,checkboxname){
        for(var i=0;i<form.elements.length;i++){
          var obj = form.elements[i];
          if(obj.name==checkboxname)
            if(obj.checked == true){
              return true;
            }
        }
       return false;
    }
      

  4.   

    <input type = checkbox name= a value = a1>a1
    <input type = checkbox name= a value = b1 checked>b1
    <input type = checkbox name= a value = c1 checked>c1
    <input type = checkbox name= a value = d1>d1<script>
    function check()
    {
      aa= document.getElementsByName('a');
      for (i=0;i<aa.length;i++)
      {
        if (aa[i].checked == false)
         alert(aa[i].value+'没有选中');
      }
    }
    check();
    </script>
      

  5.   

    <input type = checkbox name= a value = a1>a1
    <input type = checkbox name= a value = b1 checked>b1
    <input type = checkbox name= a value = c1 checked>c1
    <input type = checkbox name= a value = d1>d1<script>
    function check()
    {
      aa= document.getElementsByName('a');
      for (i=0;i<aa.length;i++)
      {
        if (aa[i].checked == false)
         alert(aa[i].value+'没有选中');
      }
    }
    check();
    </script>