看看DHTML手册之控件数组
for(var i=0;i<cid.length;i++)
   if(cid[i].checked)
       if(sl[i].value==""){
           alert("Can't Empty!");
           sl[i].select(); return;
       }

解决方案 »

  1.   

    复选框:<input name="cid" type="checkbox" value="<% =rscp("id")%>" checked onclick="if(this.previousSibling.previousSibling.value==''){alert('请输入数据')}">
      

  2.   

    <form name="form" method="post" action="" onsubmit="check()">while not rs.eof文本框:<input name="sl" type="text" size="6">复选框:<input name="cid" type="checkbox" value="<% =rscp("id")%>" checked>rs.movenext
    wend</form><script language="javascript">function check(){
    if (document.all.cid.checked == true)
        if (document.all.s1.value == "") {
          alert ("the value is null;
          document.all.s1.focus();
          return false;
        }
        else
          return true;
    }
      

  3.   

    <script language="javascript">function check(){
    if (document.all.cid.checked == true)
        if (document.all.s1.value == "") {
          alert ("the value is null;
          document.all.s1.focus();
          return false;
        }
        else
          return true;
    }
    </script>
      

  4.   

    <form name="form" method="post" action="" onsubmit="return check()">
      

  5.   

    <script language="javascript">
    function check()
    {
    var i=0;
    while(i<=form1.elements .length-2)
    {
    if(form1.elements[i+1].checked==true && form1.elements[i].value=="")
    {
    alert("您既然已经选中了此项目,那么就必须在此项目中输入!");
    form1.elements [i].focus();
    return false;
    }
    i=i+2;
    }

    return true;
    }
    </script>
    <form name="form3" method="post" action="" onsubmit="return check()>
    while not rs.eof文本框:<input name="sl" type="text" class="kuang" id="sl" size="6">复选框:<input name="cid" type="checkbox" value="<% =rscp("id")%>">rs.movenext
    wend
    </form>