Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ilx.mac

macrumors member
Original poster
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!
 
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).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.