var begintime=document.add.begintime.value;
 
 if(begintime=="")
 {
 alert("请输入开始时间");
 document.add.begintime.focus();
 return false;
 }
 var endtime=document.addgc.endtime.value
 if(endtime=="")
 {
 alert("请输入结束时间");
 document.add.endtime.focus();
 return false;
 }

解决方案 »

  1.   


    <script  src="..\images\setday.js"></script><script language="javascript">function checkform()

    var begintime=document.add.begintime.value;
     
     if(begintime=="")
     {
     alert("请输入工程开始时间");
     add.begintime.focus();
     return false;
     }
     var endtime=document.add.endtime.value
     if(endtime=="")
     {
     alert("请输入工程结束时间");
     add.endtime.focus();
     return false;
     }....
     }
    <form name=add   method="post" action="add.asp" onsubmit="javascript:return checkform()">
      <table>    <tr>
          <td width="110" height="36">&nbsp;开始时间</td>
          <td width="224" height="36"><INPUT   size="12"  id="starttime1"  name="begintime" runat="server">&nbsp;
             <input type="image" onclick="setday(this,document.getElementById('starttime1'))" src="..\images\smallclock3.gif">
           </td>
          <td width="90" height="36">&nbsp;&nbsp; 结束时间</td>          
          <td width="268" height="36"><INPUT  id="starttime3" size="12" name="endtime" runat="server">&nbsp;
        <input type="image" onclick="setday(this,document.getElementById('starttime3'))" src="..\images\smallclock7.gif" >
          </td>
        </tr>
    </table></form>
    重新贴一下
    照SHOWBO改了还是一样 是不是这段代码的问题
    <input  size="12"  id="starttime1"  name="begintime" runat="server">&nbsp;
     <input type="image" onclick="setday(this,document.getElementById('starttime1'))" src="..\images\smallclock3.gif">
      

  2.   

    你都没改代码...........
     if(begintime=="")
     {
     alert("请输入开始时间");
     document.add.begintime.focus();
     return false;
     }
     var endtime=document.addgc.endtime.value
     if(endtime=="")
     {
     alert("请输入结束时间");
     document.add.endtime.focus();
     return false;
     }
      

  3.   

    先把页面上别的东西去掉 值留2个text
      

  4.   

    由于
    add.begintime.focus();语法有错,所以后面的return false没执行了.所以就继续ACTION提交了..改一下加一下document.就行
    function checkform()

    var begintime=document.add.begintime.value;
     
     if(begintime=="")
     {
     alert("请输入开始时间");
     document.add.begintime.focus();
     return false;
     }
     var endtime=document.addgc.endtime.value
     if(endtime=="")
     {
     alert("请输入结束时间");
     document.add.endtime.focus();
     return false;
     }....
     }
      

  5.   

    不是DOCUMENT的问题,没加也可以执行