<form action="test.php" method=get onsubmit="checkform()">
<input name="chk1" type=checkbox>
<input type=submit>
</form>
<script>
function checkform(){//检查名为chk1的复选框,其他的同理
if(document.all.chk1.checked==false){
alert("选中后再提交");
event.returnValue = false;
}}
</script>

解决方案 »

  1.   

    你是不是要求所有的复选框都选中后才能提交?
    如果是这样,比较好办
    <form id=form1>
    <input type=checkbox name="cbxItem">
    <input type=checkbox name="cbxItem">
    <input type=checkbox name="cbxItem">
    <input type=checkbox name="cbxItem">
    </form>
    <script>
    funtion validate(){
       var oCbx = document.form1.all("cbxItem");
       for(var i = 0; i < oCbx.length; i++)
           if(oCbx.item(i).checked) return true;
       return false;
    }
    </script>
      

  2.   

    错了,应该是:
    <script>
    funtion validate(){
    var oCbx = document.form1.all("cbxItem");
    for(var i = 0; i < oCbx.length; i++)
    if(!oCbx.item(i).checked) return false;
    return true;
    }
    </script>
      

  3.   

    至少有一个复选框,我写的也与上面的相似,关键是在检查完复选框之后要提交到新的页面,这时需要把文本框中的值带入到新的页面中。
    我写的代码如下:
     
    <Script language="Javascript">
    <!--
    function save(){   for(i=0;i<=document.form1.elements.length-1;i++){
    var el=document.form1.elements.item(i);
    var sel=false; if (el.className=="CheckCls") {
       if (el.checked==true) {
    sel=true;
    break;
       }

    }
      }  if (sel==true){
           var body=document.form1.body.value;
    window.open('../LeaderEdit/DailyAdd.asp?WriteDate=<%=dateWentToSetDay%>&Body=body','right');
    }

      else
    {
    alert("您没有选择日期,请先选择日期");
            return; 
           }
      }</Script>