Jump to content

[SOLVED] stuck on date of birth validation.


sudsy1970

Recommended Posts

Hi all,

 

i have a new member register form on my website in which i ask for a dob.  i would like to check that a valid date of birth is entered. however the more i look at it the harder it seems to get.

 

i was thinking that i could use the following code.

$date = explode("/", "9/2/1983");
$day = $date[0];
$month = $date[1];
$year = $date[2];

 

to check each part, day should be 0 and 31, month 1 and 12 and say year  greater than 1920 but less than 2008.

 

so the first problem i have is the format  of the string.

 

i.e the American format of (year/month/day) or British (day/month/year)

 

how can i convert the string in order to check it or ensure that it is a set format ?

 

then what if someone uses  14-09-2007 instead of / does the explode statement still work?

 

then there is the leap year and month issues that i have no clue about.

such as if someone puts 29 Feb when not a leap year or 31 June which doesn't exist.

 

Any suggestions or clues?

 

cheers

sudsy

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.