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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.