Take a look at the IsDate() function.
Check this link for an example.
There are limitations of course and it all depends on your date structure and what you expect for input.
If you wanted your date formatted as dd/mm/yyyy but someone entered it as mm/dd/yyyy and the month and day numbers were both 12 or lower then you could tell that a mistake had been made.
I do not know how much tolerance IsDate() has for different separator characters and that is something you may have to take into account. If someone uses hyphens, underscores, spaces or backslashes rather than forward slashes you may have trouble recognizing it as a valid date.
You could use regular expressions to evaluate the value and convert typical incorrect characters into the correct ones then test the result with IsDate().
If you really want to control the date you may be better off using a date picker script or control rather than free type entry.
At my age I still learn something new every day, but I forget two others.
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.