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.   

    for(var i=0,len=reqInputs.length;i<len-2;i++){
    改这一句
    你的表中
    input type="image" src="img/queren.gif"></td>
        </tr>
      </table> 
    </fieldset>
    <input type="hidden" name="submit" value="submit">
    有两个input 是不用输入的
      

  2.   

    <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>
      

  3.   

    出现了这个错误
    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
      

  4.   

    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;
    }
      

  5.   

    出现这个错误Fatal error: Smarty error: unable to write to $compile_dir '/var/www/2009/webroot/subject/hotel_houtai/templates_s'. 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