2

我可以知道如何编写一个 ASP 代码来显示当前日期吗?例如,如果用户键入今天的日期,系统将允许,而如果用户键入以前的日期,它将阻止并显示错误消息。谢谢你。

如下是 ASP 代码

DIM PINVDATE,PTQTY

PINVDATE = Request.Form("PINVDATE")
PTQTY = Request.Form("PTQTY")

If TRIM(PINVDATE) = "" and TRIM(PTQTY) = "" Then

Msg = "** Mandatory Field not filled, please check !!!"

Response.Redirect "plan.asp?empid="& EmpID & "&Name=" & EmpName & "&EmpLevel=" & EmpLevel & "&ref=" & Msg

else

If TRIM(PINVDATE) = "" THEN

Msg = "** Date not filled, Please Check !!!"

Response.Redirect "plan.asp?empid="& EmpID & "&Name=" & EmpName & "&EmpLevel=" & EmpLevel & "&ref=" & Msg

else

if TRIM(PTQTY) = "" then

Msg = "** Quantity not filled, Please Check !!!"

Response.Redirect "plan.asp?empid="& EmpID & "&Name=" & EmpName & "&EmpLevel=" & EmpLevel & "&ref=" & Msg

END IF
END IF
END IF

<tr>
<th bgcolor="#8585A6" ><font color="white">Date</font></th>
<th colspan = 3 bgcolor="#ECE5B6" align=left><input type ="text" name="PINVDATE" style="text-align: left" size = 23 maxlength="30"/><font color='Red'>** Exp: YYYY-MM-DD</font></th>
</tr>
4

1 回答 1

1

检查Date 函数Datediff 函数

if DateDiff("d",Date(),CDate(TRIM(PINVDATE))) <> 0 Then
'show Error
于 2012-11-16T07:03:49.217 回答