monarch_684
09-02-2008, 09:33 PM
The format of the date should be mm/dd/yyyy. Why won't this work.
function checkDateFormat($birth){
//match the format of the date
if (preg_match ("/^([0-9]{2})/([0-9]{2})/([0-9]{4})$/", $birth, $parts)){
//check weather the date is valid of not
if(checkdate($parts[2],$parts[1],$parts[3]))
return true;
else
return false;
}
else
return false;
}
if(checkDateFormat($birth) != true)
echo "<h3>Your birthday must be in the format MM/DD/YYYY</h3>";
function checkDateFormat($birth){
//match the format of the date
if (preg_match ("/^([0-9]{2})/([0-9]{2})/([0-9]{4})$/", $birth, $parts)){
//check weather the date is valid of not
if(checkdate($parts[2],$parts[1],$parts[3]))
return true;
else
return false;
}
else
return false;
}
if(checkDateFormat($birth) != true)
echo "<h3>Your birthday must be in the format MM/DD/YYYY</h3>";