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;
}
if(begintime=="")
{
alert("请输入开始时间");
document.add.begintime.focus();
return false;
}
var endtime=document.addgc.endtime.value
if(endtime=="")
{
alert("请输入结束时间");
document.add.endtime.focus();
return false;
}
<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"> 开始时间</td>
<td width="224" height="36"><INPUT size="12" id="starttime1" name="begintime" runat="server">
<input type="image" onclick="setday(this,document.getElementById('starttime1'))" src="..\images\smallclock3.gif">
</td>
<td width="90" height="36"> 结束时间</td>
<td width="268" height="36"><INPUT id="starttime3" size="12" name="endtime" runat="server">
<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">
<input type="image" onclick="setday(this,document.getElementById('starttime1'))" src="..\images\smallclock3.gif">
if(begintime=="")
{
alert("请输入开始时间");
document.add.begintime.focus();
return false;
}
var endtime=document.addgc.endtime.value
if(endtime=="")
{
alert("请输入结束时间");
document.add.endtime.focus();
return false;
}
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;
}....
}