Hi,
I'm asking for a date in a text box, and requesting they use the following format mm-dd-yyyy. In my form validation routine, I need to check that this is indeed the format entered, and that the date is an actual valid date.
I'm assuming the format check needs to be done with reg expressions, but I'm not sure exactly how to do this.
Also, the date check should be easy to do with checkdate.
Can someone help with the reg expression?
Thanks Much,
Josh
Validated Given Date
Moderator: General Moderators
Code: Select all
if (preg_match("#ї0-9]{2}-ї0-9]{2}-ї0-9]{4}#", $string, $matches))
{
echo "IT'S A MATCH!"
}Let me know if it works for you.
This works great...
Thanks a lot.!
Code: Select all
if (preg_match("#ї0-9]{2}-ї0-9]{2}-ї0-9]{4}#", $subs, $matches) == 0)
{
$errorst .= "Invalid Date Format, <br>";
}