日期判断出错,求高手修改代码

wgdong1001 2006-12-06 06:06:37
<html>
<head>
<title>年月日</title>
</head>
<body>
<SCRIPT language=javascript>
function checkit(){
if(document.form1.col_month_1.value==2 && document.form1.col_day_1.value>29){
alert("请选择正确的日期!");
document.form1.col_day_1.focus();
return false;
}
if(document.form1.col_month_1.value==4 && document.form1.col_day_1.value>30){
alert("请选择正确的日期!");
document.form1.col_day_1.focus();
return false;
}
if(document.form1.col_month_1.value==6 && document.form1.col_day_1.value>30){
alert("请选择正确的日期!");
document.form1.col_day_1.focus();
return false;
}
if(document.form1.col_month_1.value==9 && document.form1.col_day_1.value>30){
alert("请选择正确的日期!");
document.form1.col_day_1.focus();
return false;
}
if(document.form1.col_month_1.value==11 && document.form1.col_day_1.value>30){
alert("请选择正确的日期!");
document.form1.col_day_1.focus();
return false;
}

if(document.form1.col_month_2.value==2 && document.form1.col_day_2.value>29){
alert("请选择正确的日期!");
document.form1.col_day_2.focus();
return false;
}
if(document.form1.col_month_2.value==4 && document.form1.col_day_2.value>30){
alert("请选择正确的日期!");
document.form1.col_day_2.focus();
return false;
}
if(document.form1.col_month_2.value==6 && document.form1.col_day_2.value>30){
alert("请选择正确的日期!");
document.form1.col_day_2.focus();
return false;
}
if(document.form1.col_month_2.value==9 && document.form1.col_day_2.value>30){
alert("请选择正确的日期!");
document.form1.col_day_2.focus();
return false;
}
if(document.form1.col_month_2.value==11 && document.form1.col_day_2.value>30){
alert("请选择正确的日期!");
document.form1.col_day_2.focus();
return false;
}

if(document.form1.col_year_1.value > document.form1.col_year_2.value){
alert("请选择正确年份!");
document.form1.col_year_2.focus();
return false;
}
if(document.form1.col_year_1.value == document.form1.col_year_2.value && document.form1.col_month_1.value > document.form1.col_month_2.value){
alert("请选择正确月份!");
document.form1.col_month_2.focus();
return false;
}

if(document.form1.col_year_1.value == document.form1.col_year_2.value){
if(document.form1.col_month_1.value == document.form1.col_month_2.value && document.form1.col_day_1.value > document.form1.col_day_2.value){
alert("请选择正确日期!");
document.form1.col_day_2.focus();
return false;

}

}

}
</SCRIPT>
<form name="form1" method="post" action="" enctype="" onSubmit="return checkit();">

<input type="hidden" name="flag" value="save">
时间: 


<p><select name="col_year_1">
<%
for x = 2006 to 2020

Response.Write("<option value="&x&" ")
if col_year_1 <> "" then
if x = CInt(col_year_1) then
Response.Write("selected")
end if
else
if x = year(now()) then
Response.Write("selected")
end if
end if

Response.Write(">"&x&"</option>")

next
%>
</select>年
<select name="col_month_1">
<%
for x = 1 to 12

Response.Write("<option value="&x&" ")
if col_month_1 <> "" then
if x = CInt(col_month_1) then
Response.Write("selected")
end if
else
if x = month(now()) then
Response.Write("selected")
end if
end if

Response.Write(">"&x&"</option>")

next
%>
</select>月
<select name="col_day_1">
<%
for x = 1 to 31

Response.Write("<option value="&x&" ")
if col_day_1 <> "" then
if x = CInt(col_day_1) then
Response.Write("selected")
end if
else
if x = day(now()) then
Response.Write("selected")
end if
end if
Response.Write(">"&x&"</option>")

next
%>
</select>
日--
<select name="col_year_2">
<%
for x = 2006 to 2020

Response.Write("<option value="&x&" ")
if col_year_2 <> "" then
if x = CInt(col_year_2) then
Response.Write("selected")
end if
else
if x = year(now()) then
Response.Write("selected")
end if
end if

Response.Write(">"&x&"</option>")

next
%>
</select>年
<select name="col_month_2">
<%
for x = 1 to 12

Response.Write("<option value="&x&" ")
if col_month_2 <> "" then
if x = CInt(col_month_2) then
Response.Write("selected")
end if
else
if x = month(now()) then
Response.Write("selected")
end if
end if

Response.Write(">"&x&"</option>")

next
%>
</select>月
<select name="col_day_2">
<%
for x = 1 to 31

Response.Write("<option value="&x&" ")
if col_day_2 <> "" then
if x = CInt(col_day_2) then
Response.Write("selected")
end if
else
if x = day(now()) then
Response.Write("selected")
end if
end if
Response.Write(">"&x&"</option>")

next
%>
</select>日</p><input type="submit" value="提交" name="B1" checked>
</form>
</body>
</html>
帮我看看这段程序为什么当日期选择会出错
...全文
73 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
为达到最佳效果,推荐使用九网互联的ASP空间,支持绑定域名到目录。1.03版本做了以下调整用管理员身份登陆后添加修改和回复过程(两者与添加留言同用一个表单)saveedit,edit添加新变量isEdit====================================首先感谢网友们的测试根据网友测试结果1.02版本做了以下调整1.添加css样式table {table-layout: fixed;word-wrap:break-word;}div {word-wrap:break-word;}作用 修整 如 '!' 过多表格被撑开的问题2.修改当没有记录报错的问题参见index.asp 约225行开始3.添加转换HTML标记的函数 mfkiqpl删除了原来的 RemoveHTML作用 避免如 '','' 这类代码 导致网页显示错误的问题====================================asp酒吧简单留言板更新日期:2009-03-05官方网站:asp酒吧(www.asp98.cn) QQ群:33763448 | 10547622(为保证群内质量,入群需先到 www.asp98.cn 注册认证)本程序小巧简单 非常适合初学者学习使用 高手请路过部分地方加了注译 方便理解 如有问题请参看官方网站 或加入QQ群提问===================================Copyright 2008-2009 asp98.cn - All Rights Reserved.====================================文件说明index.asp '程序主页const.asp '常用文件md5.asp 'md5加密db.mdb '数据库======================================过程saveadd '记录留言saveedit '记录修改回复留言del '删除留言login '管理登陆chk '判断管理登陆out '退出登陆add '留言edit '修改回复留言list '留言列表Numpage '数字分页textpage '文字分页=====================================函数tlen '文字截断函数mfkiqpl '转换HTML代码函数 网上收集=====================================变量dim rs,sqldim x,y,ii,page,i,f,beginpage,endpage,showNum,Action,edit,userid,pass,isEditdim conn,connstrdim Fy_Post,Fy_Get,Fy_In,Fy_Inf,Fy_Xh,Fy_db,Fy_dbstrdim aa,bb,cc,dd,ee,ff,gg,hh,jj====================================每页显示多少条记录修改打开index.asp查找 rs.pagesize '(约160行)将后面的数值改为需要的数值默认为4-----------------------------------数字分页显示个数打开const.asp查找beginpage '(约53行)修改beginpage和endpage后面的数值默认为5------------------------------------姓名字符截断打开index.asp查找 (约224行)修改,后面的数值默认为12------------------------------------留言内容字符截断打开index.asp查找 (约228行)修改,后面的数值默认为300-------------------------------------帐号密码 admin adminMD5加密出错了就打开admin表 把pass段添上7a57a5a743894a0e 就是admin------------------------------------数据库说明book '留言表id '自动编号 留言IDname '文本 留言者姓名time '日期/时间 留言时间body '备注 留言内容email '文本 留言者emailadd '文本 留言者地址tel '文本 留言者电话reply '备注 留言回复admin '管理员表id '自动编号 管理员IDuserid '文本 管理员帐号pass '文本 管理员密码SqlIn 'sql注入记录表SqlIn_ID '自动编号 注入IDSqlIn_IP '文本 注入者IPSqlI

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧