This depends on where you want to validate the date. If you want to validate the date in the server side using ASP, it is much easier.
If you want to validate the date in the client side, it is much tougher and cumbersome since Javascript(which is the recommended way of writing client scripts) does not have reserved function for checking the validity of a date.
So let me know what kind of validation are you looking at.
Here is how I managed to get a DATE every time from the USER :0 dfrom is the input field from the user form:
if Request("dfrom" = "" then
DFROM = formatdatetime(now,2)
else
if IsDate(Request("dfrom") then
DFROM = Request("dfrom"
DFROM = Month(DFROM) & "/" & day(DFROM) & "/" & year(DFROM)
if year(DFROM) < 1970 then
DFROM = Month(DFROM) & "/" & day(DFROM) & "/" & year(now)
end if
else
DFROM = formatdatetime(now,2)
end if
end if
First I check for any date at all if none get the current date: Secondly, I verify that it was indeed a date that was entered if not default to the current date. Thirdly, I verify that they did not enter a bogus year and for some strange reason I used 1970 as a default to compare to and this way the SQL query is ALWAYS happy with the date my LOOSERS put in, Oh, Users I mean :-()
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.