Jump to content

validate date time using regex or another option


autofocus

Recommended Posts

Hi.

 

i have a form with date , time and credit card information.

 

i want to validate date, time, credit card number format(after customer select card type from visa amex and mastercard)

 

do i have to use regex?

 

or is there any built in method in php to check date and time.

 

thanks

It kind of depends on how you let the user input the date and time. You may have to convert their input accordingly. But, you may want to take a look at the following functions:

 

For date only:

http://us3.php.net/manual/en/function.checkdate.php

 

For a date & time (but a failure will not tell you which one failed)

http://us3.php.net/manual/en/function.strtotime.php

 

I'd suggest using the first function to validate the date and then use a custom function for validating the time. Again, this depends on what the input parameters are.

 

 

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.