Jump to content

Check If Date Is Valid


johnsmith153

Recommended Posts

Why not instead have 3 inputs and then join them together after validating each part? Other than that best choice is regex, something like:

 

if (preg_match('/[0-3][0-9]\/[0-1][1-9]\/[1-2][0-9][0-9][0-9]/', $date))
{
    // valid
}
else
{
    // invalid
}

 

Of course with that you run into issues with the user having to enter a forward slash between each part, when they could enter dot, hyphen, etc. Does it necessarily need to be a forward slash?

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.