Page 1 of 1

date checking doubt

Posted: Tue Jul 31, 2007 5:01 am
by avmohankumar
Dear,

If, instead of 13-01-2003, the user writes 13/01/2003, the system must show an error message.
If, instead of 13-01-2003, the user writes 13-01-03, the system must show an error message.
If, instead of 13-01-2003, the user writes 2003-01-13, the system must show an error message.
And so on…

The error message could be something like:
“Attention! The inserted date is not in the correct format.”

if we enter in one text bow the date, it should check the date.

how i can resolve this, please help me.

Regards,
avmohan

Posted: Tue Jul 31, 2007 5:21 am
by volka
Split the string on "-"
show an error message if
- the resulting array does not have exactly 3 elements
- the last element does not have exactly 4 digits
- checkdate() returns false

see http://php.net/explode and http://php.net/checkdate

thank you

Posted: Tue Jul 31, 2007 5:28 am
by avmohankumar
Dear,

Thank you very much,

I will proceed the things as you said, thanks a lot.

Regards,
avmohan