Date Format Validation

Discussion in 'iOS Programming' started by ilx.mac, Nov 5, 2009.

  1. ilx.mac macrumors member

    Mar 10, 2009
    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!
  2. Troglodyte macrumors member

    Jul 2, 2009
    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).

Share This Page