Regular expression for validating Date format dd/MM/yyyy

Last post 11-10-2009 12:33 AM by vizvin. 7 replies.

Sort Posts:

  • Regular expression for validating Date format dd/MM/yyyy

    04-15-2009, 2:47 AM
    • Contributor
      2,362 point Contributor
    • Rameezwaheed
    • Member since 08-31-2008, 6:51 AM
    • Posts 984

    Hi,

    What would be regular Expression for validating Date format like dd/MM/yyyy.?

    Best Regards

    life is name of learning!
    Mark as an answer if it helps
  • Re: Regular expression for validating Date format dd/MM/yyyy

    04-15-2009, 3:27 AM
    Answer
    • All-Star
      21,760 point All-Star
    • venkatu2005
    • Member since 07-01-2008, 10:48 AM
    • Posts 4,684

    Rameezwaheed:
    What would be regular Expression for validating Date format like dd/MM/yyyy.?
     

    Regex: matches a date in dd/mm/yyyy format


    ^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/((20[0-9][0-9])|(19[0-9][0-9])))|((29\/02\/(19|20)(([02468][048])|([13579][26]))))$ 

    I have Changed My Blog from (http://venkat-dotnetsamples.blogspot.com) to (http://venkat-dotnetsnippets.blogspot.com)

    Regards,
    Venkatesan.M

    Please Mark as Answered If its helpful and Un-Mark as Answered if it not help u.
  • Re: Regular expression for validating Date format dd/MM/yyyy

    04-15-2009, 3:32 AM
    Answer
    • All-Star
      15,283 point All-Star
    • yasserzaid
    • Member since 09-22-2007, 9:10 PM
    • Egypt
    • Posts 2,586

    Hi

    Use this following Regular Expression Details, This will support leap year also.

    ^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$


    Matches
    [29/02/2000], [30/04/2003], [01/01/2003]

    Non-Matches
    [29/02/2001], [30-04-2003], [1/1/1899]

    or check this link http://www.codeproject.com/KB/aspnet/LengthValidation.aspx

    http://www.java2s.com/Tutorial/JavaScript/0520__Regular-Expressions/UseRegularExpressiontovalidatedate.htm

    Good Luck

    Yasser Zaid
    My Blog [http://yasserzaid.wordpress.com/]
  • Re: Regular expression for validating Date format dd/MM/yyyy

    04-15-2009, 3:35 AM
    Answer
    • Star
      9,788 point Star
    • shashankgwl
    • Member since 09-19-2008, 3:18 PM
    • MUMBAI
    • Posts 1,931

    google will give you 20400 results for your query

    http://www.google.co.in/search?q=Regular+expression+for+validating+Date+format+dd%2FMM%2Fyyyy&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

    SHASHANK BHIDE
    CAPGEMINI INDIA
    "THE ROAD TO SUCCESS IS ALWAYS UNDER CONSTRUCTION MARK MY RESPONSE AS ANSWER TO HELP ME BUILD IT Wink "
  • Re: Regular expression for validating Date format dd/MM/yyyy

    04-15-2009, 4:17 AM
    Answer
    • Contributor
      2,326 point Contributor
    • susain
    • Member since 10-29-2007, 11:51 AM
    • Hyderabad, Andhra Pradesh, India
    • Posts 651

    Hi Rameez,

    Checkout http://regexlib.com/DisplayPatterns.aspx?cattabindex=4&categoryId=5

    This is good site where you can find regular expressions to use for future http://regexlib.com/Default.aspx

    Thanks,

    Farooq

    Linked In: http://www.linkedin.com/in/mohammedfarooq123

    Mark as answer if this post help full to you.
  • Re: Regular expression for validating Date format dd/MM/yyyy

    04-15-2009, 4:45 AM

    Hi,

     

    There is a very simple and nice way using ajax, ASP.NET AJAX MaskedEdit . Check this link http://www.asp.net/learn/ajax-videos/video-131.aspx

     

  • Re: Regular expression for validating Date format dd/MM/yyyy

    04-15-2009, 8:01 AM
    • Contributor
      2,362 point Contributor
    • Rameezwaheed
    • Member since 08-31-2008, 6:51 AM
    • Posts 984

    Thanks for all for shairing Ideas ,

     

    I got it working and surely marked the post(s) as answer which helped me .

    once again thanks for all.

    Best Regards

    life is name of learning!
    Mark as an answer if it helps
  • Re: Regular expression for validating Date format dd/MM/yyyy

    11-10-2009, 12:33 AM
    • Member
      2 point Member
    • vizvin
    • Member since 11-10-2009, 12:30 AM
    • Posts 1

    I liked the leap year support.. Could you help me with a similar one?..my date format would be either "ddMMyyyy" or "MMddyyyy"


    Thanks in advance.

Page 1 of 1 (8 items)