This is the regular expression I am using:
if (preg_match("/^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$/", $_POST["collection-date"]) === 0) {
$errors .= "\n Error: Invalid Collection Date";
$collectiondate = FALSE;
}
Currently $_POST['collection-date'] equals 15/02/2012 and it still returns false. Why is this?
Thank you for any suggestions.
This also validates false if someone enters an invalid date, such as
99/99/2012or31/02/2012, which you probably want as well.