php程序啊
在linux上添加文件,使用JS判断文本框不能为空,可是我在文本框中输入数据后,点击确认后,还是显示“不能为空”.
js //文本框确认
 function Check(){
  // var reqInputs=document.getElementsByName("text_name");
  reqInputs=document.getElementsByTagName("input");
   for(var i=0,len=reqInputs.length;i<len;i++){
       if(reqInputs[i].value.length==0){
           alert("请输入指定的信息");
           reqInputs[i].focus();
           return false;
       }
   }
   return true;
}htm<form name="form1" action="login.php" method="POST" onsubmit="return Check();">
<fieldset style="width:400px; ">
 <legend style="color:#8492B5;">数据添加</legend>
   <table align="right" >
    <tr>
     <td width="100" height="30" class="wenzi" ><img src="img/38.gif" width="10" height="10"/>id:</td>
     <td width="300" align="left" class="zhushi"><input type="text" id="text_name" name="hot" value="">*输入数字</td>
    </tr>
    <tr>
      <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>开始时间:</td>
      <td align="left" class="zhushi">
        <input type="text" id="text_name" name="start" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
    </tr>
    <tr>
      <td height="30" class="zi" ><img src="img/38.gif" width="10" height="10"/>结束时间:</td>
      <td align="left" class="zhushi">
        <input type="text" id="text_name" name="end"  onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
    </tr>
    <tr>
     <td height="30" class="wenzi"><img src="img/38.gif" width="10" height="10"/>备&nbsp;&nbsp;注:</td>
     <td align="left" class="zhushi">
     <input type="text" id="text_name" name="sre" value="" >*输入中文</td>
    </tr>
    <tr>
      <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>s_type:</td>
      <td align="left" class="zhushi"><input type="text" name="s_tp" value="">&nbsp;输入数字</td>
    </tr>
    <tr>
      <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>内容:</td>
      <td width="388">&nbsp;</td>
    </tr>
    <tr>
      <td align="left" colspan="2" class="zhushi">&nbsp;&nbsp;&nbsp;&nbsp;
       <textarea name="ctn" id="text_name" style="width:300px; height:50px;"></textarea>*输入中文
      </td>
    </tr>
    <tr>
      <td align="center" height="50" colspan="2" ><input type="image" src="img/queren.gif"></td>
    </tr>
  </table> 
</fieldset>
<input type="hidden" name="submit" value="submit">
</form>

解决方案 »

  1.   

     //文本框确认
     function Check(){
      // var reqInputs=document.getElementsByName("text_name");
      reqInputs=document.getElementsByTagName("input");
       for(var i=0,len=reqInputs.length;i<len;i++){
           if(reqInputs[i].value==""){
               alert("请输入指定的信息");
               reqInputs[i].focus();
               return false;
           }
       }
       return true;
    }
      

  2.   

    //文本框确认
     function Check(){
      // var reqInputs=document.getElementsByName("text_name");
      reqInputs=document.getElementsByTagName("input");
       for(var i=0; i<reqInputs.length; i++){
           if(reqInputs[i].value==""){
               alert("请输入指定的信息");
               reqInputs[i].focus();
               return false;
           }
       }
       return true;
    }
      

  3.   

    楼主要注意tagname是input的是7个,而type为text的是5个,这样你循环的次数是不行的
      

  4.   

    还有页面中的id重复,id是不能重复的
      

  5.   

    楼上正解
    你多了
    <input type="image" src="img/queren.gif"></td>
     
    <input type="hidden" name="submit" value="submit">
      

  6.   

    js和html都改了点,所以一定要都复制过去
    <script language="javascript">
    //文本框确认
    function Check(){
    for(var i=1;i<7;i++){
    if(document.getElementById("text_name" + i).value.length==0){
    alert("请输入指定的信息");
    document.getElementById("text_name" + i).focus();
    return false;
    }
    }
    return true;
    }
    </script>
    <form name="form1" action="login.php" method="POST" onsubmit="return Check();">
    <fieldset style="width:400px; ">
     <legend style="color:#8492B5;">数据添加</legend>
       <table align="right" >
        <tr>
         <td width="100" height="30" class="wenzi" ><img src="img/38.gif" width="10" height="10"/>id:</td>
         <td width="300" align="left" class="zhushi"><input type="text" id="text_name1" name="hot" value="">*输入数字</td>
        </tr>
        <tr>
          <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>开始时间:</td>
          <td align="left" class="zhushi">
            <input type="text" id="text_name2" name="start" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
        </tr>
        <tr>
          <td height="30" class="zi" ><img src="img/38.gif" width="10" height="10"/>结束时间:</td>
          <td align="left" class="zhushi">
            <input type="text" id="text_name3" name="end"  onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
        </tr>
        <tr>
         <td height="30" class="wenzi"><img src="img/38.gif" width="10" height="10"/>备&nbsp;&nbsp;注:</td>
         <td align="left" class="zhushi">
         <input type="text" id="text_name4" name="sre" value="" >*输入中文</td>
        </tr>
        <tr>
          <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>s_type:</td>
          <td align="left" class="zhushi"><input type="text" id="text_name5" name="s_tp" value="">&nbsp;输入数字</td>
        </tr>
        <tr>
          <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>内容:</td>
          <td width="388">&nbsp;</td>
        </tr>
        <tr>
          <td align="left" colspan="2" class="zhushi">&nbsp;&nbsp;&nbsp;&nbsp;
           <textarea name="ctn" id="text_name6" style="width:300px; height:50px;"></textarea>*输入中文
          </td>
        </tr>
        <tr>
          <td align="center" height="50" colspan="2" ><input type="image" src="img/queren.gif"></td>
        </tr>
      </table> 
    </fieldset>
    <input type="hidden" name="submit" value="submit">
    </form>
      

  7.   


    <?phpheader("Content-type: text/html; charset=gb2312");
    ?>
    <html>
    <head>
    <script language="javascript" type="text/javascript">
    function Check(){
      // var reqInputs=document.getElementsByName("text_name");
      reqInputs=document.getElementsByTagName("input");
      alert(reqInputs.length);
       for(var i=0;i<reqInputs.length;i++){
       if(reqInputs[i].type=="text")
       {
           if(reqInputs[i].value==""){
               alert("请输入指定的信息");
               reqInputs[i].focus();
               return false;
           }
       }
       }
       return true;
    }
    function WdatePicker()
    {}</script></head>
    <body>
    <form name="form1" action="login.php" method="POST" onsubmit="return Check();">
    <fieldset style="width:400px; ">
     <legend style="color:#8492B5;">数据添加</legend>
       <table align="right" >
        <tr>
         <td width="100" height="30" class="wenzi" ><img src="img/38.gif" width="10" height="10"/>id:</td>
         <td width="300" align="left" class="zhushi"><input type="text" id="text_name" name="hot" value="">*输入数字</td>
        </tr>
        <tr>
          <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>开始时间:</td>
          <td align="left" class="zhushi">
            <input type="text" id="text_name" name="start" >*格式:年-月-日</td>
        </tr>
        <tr>
          <td height="30" class="zi" ><img src="img/38.gif" width="10" height="10"/>结束时间:</td>
          <td align="left" class="zhushi">
            <input type="text" id="text_name" name="end"  >*格式:年-月-日</td>
        </tr>
        <tr>
         <td height="30" class="wenzi"><img src="img/38.gif" width="10" height="10"/>备&nbsp;&nbsp;注:</td>
         <td align="left" class="zhushi">
         <input type="text" id="text_name" name="sre" value="" >*输入中文</td>
        </tr>
        <tr>
          <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>s_type:</td>
          <td align="left" class="zhushi"><input type="text" name="s_tp" value="">&nbsp;输入数字</td>
        </tr>
        <tr>
          <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>内容:</td>
          <td width="388">&nbsp;</td>
        </tr>
        <tr>
          <td align="left" colspan="2" class="zhushi">&nbsp;&nbsp;&nbsp;&nbsp;
          
          </td>
        </tr>
        <tr>
          <td align="center" height="50" colspan="2" ><input type="image" src="img/queren.gif"></td>
        </tr>
      </table> 
    </fieldset>
    <input type="submit" name="submit" value="submit">
    </form></body>
    </html>你注意了 你reqInputs=document.getElementsByTagName("input");之后有7个input 标签  你要验证的是input type="text"的标签
      

  8.   

    出现了这个错误
    Fatal error: Smarty error: unable to write to $compile_dir '/var/www/2009/webroot/subject/hotel_houtai/templates_c'. Be sure $compile_dir is writable by the web server user. in /var/www/2009/webroot/subject/hotel_houtai/libs/Smarty.class.php on line 1092
      

  9.   

    function Check(){
      // var reqInputs=document.getElementsByName("text_name");
      reqInputs=document.getElementsByTagName("input");
       for(var i=0,len=reqInputs.length;i<len;i++){
           if(reqInputs[i].type == 'text' && reqInputs[i].value.length==0){
               alert("请输入指定的信息");
               reqInputs[i].focus();
               return false;
           }
       }
       return true;
    }
      

  10.   

    现在我改成这个
    <script language="javascript"> //文本框确认 function Check(){ for(var i=1;i<7;i++){ if(document.getElementById("text_name" + i).value.length==0){ alert("请输入指定的信息"); document.getElementById("text_name" + i).focus(); return false; } } return true; } </script> <form name="form1" action="login.php" method="POST" onsubmit="return Check();"> <fieldset style="width:400px; ">  <legend style="color:#8492B5;">数据添加</legend>  <table align="right" >  <tr>  <td width="100" height="30" class="wenzi" ><img src="img/38.gif" width="10" height="10"/>id:</td>  <td width="300" align="left" class="zhushi"><input type="text" id="text_name1" name="hot" value="">*输入数字</td>  </tr>  <tr>  <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>开始时间:</td>  <td align="left" class="zhushi">  <input type="text" id="text_name2" name="start" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>  </tr>  <tr>  <td height="30" class="zi" ><img src="img/38.gif" width="10" height="10"/>结束时间:</td>  <td align="left" class="zhushi">  <input type="text" id="text_name3" name="end" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>  </tr>  <tr>  <td height="30" class="wenzi"><img src="img/38.gif" width="10" height="10"/>备&nbsp;&nbsp;注:</td>  <td align="left" class="zhushi">  <input type="text" id="text_name4" name="sre" value="" >*输入中文</td>  </tr>  <tr>  <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>s_type:</td>  <td align="left" class="zhushi"><input type="text" id="text_name5" name="s_tp" value="">&nbsp;输入数字</td>  </tr>  <tr>  <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>内容:</td>  <td width="388">&nbsp;</td>  </tr>  <tr>  <td align="left" colspan="2" class="zhushi">&nbsp;&nbsp;&nbsp;&nbsp;  <textarea name="ctn" id="text_name6" style="width:300px; height:50px;"></textarea>*输入中文 </td>  </tr>  <tr>  <td align="center" height="50" colspan="2" ><input type="image" src="img/queren.gif"></td>  </tr>  </table> </fieldset> <input type="hidden" name="submit" value="submit"> </form>
      

  11.   

    smarty的错误 跟js无关 你smarty的代码
      

  12.   

    linux服务器?应该templates_c这个文件夹没有权限 
    chmod 777