validating mmddyy in php using javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • laasyavadlamudi
    New Member
    • Mar 2010
    • 1

    validating mmddyy in php using javascript

    please kindly let me know how can i validate a date in the format of mmddyy
    in side the form i mean when i enter a wrong date field along with otger fields like name adress etc
    when date is entered wrong and not in the format mmddyy
    how to solve that issue
    please can some one help me
    thansk
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    First, let the user know what format you're expecting

    Second, Optionally, you can script JavaScript to validate the date when the field is blurred().

    Thirdly, You should always have PHP validate that format.

    Here's a regular expression that accepts that date format, but doesn't account for February end-days.

    Code:
    (0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])(19|20)[0-9]{2}
    The above accepts date formats such as

    12/30/1995
    02/31/2015

    but not like

    15/20/99
    1/1/95


    Cheers,






    Dan

    Comment

    Working...