hi, I am trying to add a date validation to my form processor so that if the date format is not in this format yyyy-mm-dd then it will echo incorrect. Any ideas what i would need to do anyone? Cheers, Adam
list($year, $month, $day) = array_map('intval', explode('-', $date)); if (!checkdate($month, $day, $year)) { // Throw error } PHP: Does not only check if the date is in a valid format, it does also check if the date exists.
Thanks for that nico.. From looking at the would i have to assign the post[] value to $date for this to work?
Yes. $date = $_POST['whatever-key-you-are-using']; PHP: Or replace $date with the $_POST variable in the code above. Btw, it's easier and less confusing for the user if you use drop downs with the dates. This way you'll get it in the correct format and it's just easier.