for(var i=0;i<...){
document.getElementById("add"+i).value
}是这个意思不?

解决方案 »

  1.   

    document.form.add[i].value.length== 0  
    or 
    document.form.add[i].value.length <1
    or 
    document.form.add[i].value == "" 
      

  2.   

    "add <%=i%>"
    这个不能有空格吧,用下划线试一下
      

  3.   

    <script type="text/javascript"> 
    function beforeSubmit(form){ 
    for (i=1 to <%=Session("count")%> ){ 
      if(document.getElementById("add"+i).value == ''){ /*疑点*/ 
        alert('title not empty!'); 
        document.form.add[i-1].focus(); 
        return false; 
      } 

    for (i=1 to <%=Session("count")%> ){ 
      if(document.getElementById("content"+i).value == ''){ /*疑点*/ 
        alert(content not empty!'); 
        document.form.content[i-1].focus(); 
        return false; 
      } 
    }} 
    </script> 
    <form id="form" name="form1" method="get" action="insert.asp" onSubmit="return beforeSubmit(this);"> 
    <%for i=1 to count %> 
      <div> 
          标题: <input type="text"  name="add <%=i%>" id="add <%=i%>"/> 
          内容: <input type="text"  name="content <%=i%>" id="content <%=i%>"/> 
      </div> 
      <%next %> 
      <input type="submit" value="提交"/> 
    </form>