PDA

View Full Version : Date Format Validation




ilx.mac
Nov 6, 2009, 01:26 AM
Hi There,

I have a text field, where the user can enter date & press submit button. I need to validate the user entered text to the date format (MM/dd/yyyy). Is there a way to get that?

Add Info: The user may also enter alpha-numeric ex: 12/we-3f in date text field. Also is there a way to restrict user to enter numeric along with special character '/'.

I must not use date picker!

Thanks in Advance!



Troglodyte
Nov 6, 2009, 02:37 AM
What does 12/we-3f mean?

Also remember that much of the world outside the US uses dd/mm/yyyy. Are you going to have you app available outside the US?

If you just stick to mm/dd/yyyy then validation is simple. Make sure it's in the required format, split the string up and validate each field separately. The most complex field is the dd but even then you just have an array of days in the month (and of course you allow for leap years).