看看下面的吧,其实很简单的!
<%
year2=request("year")
month2=request("month")
date2=request("date")
year1=request("year1")
month1=request("month1")
date1=request("date1")
if cint(year2)>cint(year1) then
response.write "<script>alert('起始时间应该小于终结时间!');history.back();</script>"
elseif cint(year2)=cint(year1) and cint(month2)>cint(month1) then
response.write "<script>alert('起始时间应该小于终结时间!');history.back();</script>"
elseif cint(year2)=cint(year1) and cint(month2)=cint(month1) and cint(date2)>cint(date1) then
response.write "<script>alert('起始时间应该小于终结时间!');history.back();</script>"
end if
if month2="2" then
if (cint(year2) mod 4)<>0 and cint(date2)>28 then
response.write "<script>alert('请选择正确的时间!');history.back();</script>"
elseif (cint(year2) mod 4)=0 and cint(date2)>29 then
response.write "<script>alert('请选择正确的时间!');history.back();</script>"
end if
end if
if month1="2" then
if (cint(year1) mod 4)<>0 and cint(date1)>28 then
response.write "<script>alert('请选择正确的时间!');history.back();</script>"
elseif (cint(year1) mod 4)=0 and cint(date1)>29 then
response.write "<script>alert('请选择正确的时间!');history.back();</script>"
end if
end if
if month2="4" or month2="6" or month2="9" or month2="11" then
if date2="31" then
response.write "<script>alert('请选择正确的时间!');history.back();</script>"
end if
end if
if month1="4" or month1="6" or month1="9" or month1="11" then
if date1="31" then
response.write "<script>alert('请选择正确的时间!');history.back();</script>"
end if
end if
straccess="select * from law where (addtime between CONVERT(datetime(8), '" & year2 & "-" & month2 & "-" & date2 & " 00:00:00') and CONVERT(datetime(8),'" & year1 & "-" & month1 & "-" & date1 & " 00:00:00'))"
set rst=server.createobject("adodb.recordset")
rst.cursortype=1
rst.locktype=3
rst.open straccess,strconn
do while not rst.eof
rst.delete
rst.updatebatch
rst.close
set rst=nothing
rst.movenext
loop
rst.close
set rst=nothing
response.write "<script>alert('成功删除!');history.back();</script>"
%>
//函数名:chkdate
//功能介绍:检查是否为日期
//参数说明:要检查的字符串
//返回值:0:不是日期 1:是日期
function chkdate(datestr)
{
var lthdatestr
if (datestr != "")
lthdatestr= datestr.length ;
else
lthdatestr=0;
var tmpy="";
var tmpm="";
var tmpd="";
//var datestr;
var status;
status=0;
if ( lthdatestr== 0)
return 0
for (i=0;i<lthdatestr;i++)
{ if (datestr.charAt(i)== '-')
{
status++;
}
if (status>2)
{
//alert("Invalid format of date!");
return 0;
}
if ((status==0) && (datestr.charAt(i)!='-'))
{
tmpy=tmpy+datestr.charAt(i)
}
if ((status==1) && (datestr.charAt(i)!='-'))
{
tmpm=tmpm+datestr.charAt(i)
}
if ((status==2) && (datestr.charAt(i)!='-'))
{
tmpd=tmpd+datestr.charAt(i)
}
}
year=new String (tmpy);
month=new String (tmpm);
day=new String (tmpd)
//tempdate= new String (year+month+day);
//alert(tempdate);
if ((tmpy.length!=4) || (tmpm.length>2) || (tmpd.length>2))
{
//alert("Invalid format of date!");
return 0;
}
if (!((1<=month) && (12>=month) && (31>=day) && (1<=day)) )
{
//alert ("Invalid month or day!");
return 0;
}
if (!((year % 4)==0) && (month==2) && (day==29))
{
//alert ("This is not a leap year!");
return 0;
}
if ((month<=7) && ((month % 2)==0) && (day>=31))
{
//alert ("This month is a small month!");
return 0;
}
if ((month>=8) && ((month % 2)==1) && (day>=31))
{
//alert ("This month is a small month!");
return 0;
}
if ((month==2) && (day==30))
{
//alert("The Febryary never has this day!");
return 0;
}
var regu = "^(['2000-2-30'])"
var re = new RegExp(regu);
if (theForm.textfile.value.search(re) == -1) {
return true;
} else {
alert ("格式错误");
return false;
}