> I am using ereg to validate the format of a date entry (mm/dd/yy), but if > the year ends in a 0, it is being stripped and as such produces an error. > So > 1990 would be 199. The dob is being inputted by a form.... > > Here is my code: > > if (!ereg("^([0-9]{2})/([0-9]{2})/([0-9]{4})$", $formsave["dob"], $parts)) > { > $error["dob"] = "*"; $message["dob"] = "Invalid date format!"; > $dob = " \"$parts[3]-$parts[2]-$parts[1]\""; > }
So is $formsave['dob'] being changed before you get to this code, causing the check to fail? What else are you doing with $formsave['dob']? Nothing here is going to cause it to drop a zero from the end. Your code doesn't make much sense, though. If the ereg() fails, $parts is not going to have any value, so why are you referencing $part[1], $part[2], etc... ? ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php