- 热门文章:
- · 表单填写时用 回车 代替 TAB 的实现方式
- · javascript里类似select case 该如何用?
- · javascript里类似select case 该如何用?
- · 在javascript 里面有没有检查日期格式的函数?
- · js中with的和case的用法
- · asp的cookie本身不设置的话默认的是application的path=/,所以不设关系不大,expires要设。给你netscape...
- · html的标准里这样写的。
- · Dreamweaver 4 & UltraDev 4两个BUG(字体设置不能保存和行号显示错位)的解决方法
- · 一个DHTML的例子——3D文字
- · 如何做页面自动刷新,又不用让用户按回车键来提交数据!(大功告成)
- · javascript对象与数组参考大全1
- · javascript对象与数组参考大全2
利用javascript实现时间段的查询
希望大家能帮我测试一下,输入的时间格式是1999-01-01或2000-10-01或2000-10-10,即月份和时间必须是两位,为了方便大家测试,把所有文件放在这里,只要运行time_main.asp就可以了,多谢了!
time_main.asp
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<FRAMESET ROWS="82,18" border=1>
<FRAME NAME="time" SRC="time.asp">
<FRAME NAME="time_search" SRC="time_search.asp">
</FRAMESET>
<NOFRAMES>您的浏览器不支持FRAMES</NOFRAMES>
</HTML>
time.asp
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
starttime = Request.Form("starttime")
endtime = Request.Form("endtime")
Response.Write starttime&"<br>"
Response.Write endtime&"<br>"
%>
请点击“查询”按钮
</BODY>
</HTML>
time_search.asp
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<center>
<form name="tform" method="post">
按时间(以<font color=red>[YYYY-MM-DD]</font>格式输入):
<input type="text" name="starttime" size=10 maxlength=10 value="1999-01-02">到
<input type="text" name="endtime" size=10 maxlength=10 value="2000-01-01">
<input type="button" name="tsearch" value="查 询" onclick="return tcheck()">
</form>
</center>
<script language="javascript">
<!--
function tcheck()
{
if (window.document.tform.starttime.value != "")
{
var vDate,vYear,vMonth,vDay;
vDate = window.document.tform.starttime.value;
vYear = vDate.substring(0,4);
if (isNaN(vYear) || vYear < 1900)
{
window.alert("您的日期1输入有误!");
tform.starttime.focus();
return false;
}
vMonth = vDate.substring(5,7);
if (isNaN(vMonth) || vMonth < 01 || vMonth > 12)
{
window.alert("您的日期1输入有误!");
tform.starttime.focus();
return false;
}
vDay = vDate.substring(8,10);
if (isNaN(vDay) || vDay == "" || vDay.length != 2 || vDay < 01 || vDay > 31)
{
window.alert("您的日期1输入有误!");
tform.starttime.focus();
return false;
}
if (vMonth == 04 || vMonth == 06 || vMonth == 09 || vMonth == 11)
{
if (vDay > 30)
{
window.alert("您的日期1输入有误!");
return false;
}
}
if (vMonth == 02)
{
if (vYear % 4 == 0 && vYear % 100 || vYear % 400 == 0)
{
if (vDay > 29)
{
window.alert("您的日期1输入有误!");
tform.starttime.focus();
return false;
}
}
else
{
if (vDay > 28)
{
window.alert("您的日期1输入有误!");
tform.starttime.focus();
return false;
}
}
}
if (vDate.substring(4,5) !== "-" || vDate.substring(7,8) != "-")
{
window.alert("您的输入有误,请以YYYY-MM-DD格式输入!");
tform.starttime.focus();
return false;
}
if (window.document.tform.starttime.value != "" && window.document.tform.endt
ime.value != "")
{
if (window.document.tform.starttime.value > window.document.tform.endtime.va
lue)
{
window.alert("起始日期不能大于终止日期!");
tform.starttime.focus();
return false;
}
}
}
if (window.document.tform.endtime.value != "")
{
var vDate,vYear,vMonth,vDay;
vDate = window.document.tform.endtime.value;
vYear = vDate.substring(0,4);
if (isNaN(vYear))
{
window.alert("您的日期2输入有误!");
tform.endtime.focus();
return false;
}
vMonth = vDate.substring(5,7);
if (isNaN(vMonth) || vMonth < 01 || vMonth > 12)
{
window.alert("您的日期2输入有误!");
tform.endtime.focus();
return false;
}
vDay = vDate.substring(8,10);
if (isNaN(vDay) || vDay == "" || vDay.length != 2 || vDay < 01 || vDay > 31)
{
window.alert("您的日期2输入有误!");
tform.endtime.focus();
return false;
}
if (vMonth == 04 || vMonth == 06 || vMonth == 09 || vMonth == 11)
{
if (vDay > 30)
{
window.alert("您的日期2输入有误!");
return false;
}
}
if (vMonth == 02)
{
if (vYear % 4 == 0 && vYear % 100 == 0 || vYear % 400 == 0)
{
if (vDay > 29)
{
window.alert("您的日期2输入有误!");
tform.endtime.focus();
return false;
}
}
else
{
if (vDay > 28)
{
window.alert("您的日期2输入有误!");
tform.endtime.focus();
return false;
}
}
}
if (vDate.substring(4,5) !== "-" || vDate.substring(7,8) != "-")
{
window.alert("您的输入有误,请以YYYY-MM-DD格式输入!");
tform.endtime.focus();
return false;
}
}
//如果必须按时间查询的话,就把注释放开就可以了
//if (window.document.tform.starttime.value == "" && window.document.tform.end
time.value == "")
//{
// window.alert("对不起,请你输入时间!");
// window.document.tform.starttime.focus();
// return false;
//}
window.document.tform.action = "time.asp";
window.document.tform.target = "time";
window.document.tform.submit();
}
//-->
</script>
</BODY>
</HTML>
下一篇:表单填写时用 回车 代替 TAB 的实现方式 >>
相关文章:
- · 一个点击后自动滚屏的例子!
- · 一个鼠标自动移动的js例子!
- · window.showModalDialog()中有三个参数,各有什么用,请举例!
- · 三级下拉框连动的数据库版!
- · 给一个类增加属性和方法?看看这个够不够?
- · 在网页中实现OICQ里的头像选择的下拉框 (附例子)
- · 请看用javascript设置和读取cookie的简单例子.....
- · 请看被打开的子窗口继承父窗口定义的styleSheets的例子
- · 经常有人询问如何用javascript判断日期是否有效,我以前也遇到过,不过后来得高人指点解决了,贴出来大...
- · ShowModalDialog的具体用法
- · 下拉式互动列表框(EC潮流网同学录之真情留言板使用的代码)
- · MSGBOX返回值
- · js中几种去掉字串左右空格的方法,请看
- · VBSctipt 5.0中的新特性
- · Jscript 5.0中的新特性
- · 加快 DHTML 的一组技巧(Copy from Microsoft)
- · 一个不太让人讨厌的自动弹出窗口:)
- · 一个把数字转英文的实用程序
- · rollarea.js及其用法示例
- · 下拉框连动的小例子(.htm版)
- · 判断访问者的浏览器是否支持javascript和Cookies
- · 在Windows桌面上使用WSH接收邮件 (转)
- · HTML4.0的 Access Key
- · 绝对是好东西 (select1 <==> select2):
- · 一个类似vbscript的round函数的javascript函数
- · 用javascript检查yyyy-mm-dd格式的正确源码。
- · HEAD元素使用集锦 (转)
- · 脚本控制Frame (转)
- · vbscript错误代码及对应解释大全
- · jscript错误代码及相应解释大全
- · 打开最大化窗口的一点经验
- · 无偿贡献,进入页面后自动刷新一次
- · 庆祝 Joy ASP 上贴数超过800页!!! 送给大家一个小礼物 ^_^
- · 自己动手,结合javascript和dhtml做一个ubb编辑器(附例子代码)
- · 选择最快的镜像站点
- · 一段有趣并且实用的程序--利用javascript和dhtml实现两个列表框中内容的移动。(代码见内,把它存为一个...
- · 动态菜单的另一种实现(一) category.js
- · 动态数组的另一种实现(二) 界面
