Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3444724
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:57:06+00:00 2026-05-18T08:57:06+00:00

We need help for regular expression that work with asp.net asp:RegularExpressionValidator to validate date

  • 0

We need help for regular expression that work with asp.net asp:RegularExpressionValidator to validate date in MMddyy format. Problem we are facing is leap year. Issue is that is it possible to verify through regular expression that it only accepts valid leap year dates like 02/29/2008 is a valid date but 02/29/2010 is not a valid date.

Any regular expression that works with “asp:RegularExpressionValidator”?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:57:07+00:00Added an answer on May 18, 2026 at 8:57 am

    OK, you asked for a regex. Here it is. I think it’s immediately obvious why it’s not a good idea to validate a date with a regular expression:

    First, the verbose, commented version to at least make understanding this beast possible:

    ^       # start of string
    (?:     # either match...
     (?:
      (?:   # 31st day of all allowed months
       (?:(?:0?[13578]|1[02])/31)
       |    # or
       (?:(?:0?[13-9]|1[0-2])/(?:29|30))
      )     # 29th/30th day of any month except February
      /     # plus any year since 1600
      (?:1[6-9]|[2-9]\d)
      \d{2}
     )
    |       # or
     (?:    # match Feb 29th
      0?2/29/
      (?:   # in all leap years since 1600
       (?:
        (?: # century
         1[6-9]|[2-9]\d
        )
        (?: # two-digit years divisible by four, not ending in 00
         0[48]
         |
         [2468][048]
         |
         [13579][26]
        )
        |
        (?: # all the leap years ending in 00
         (?:16|[2468][048]|[3579][26])
        00
        )
       )
      )
     )
    |       # or
     (?:    # (for any month)
      (?:0?[1-9])
      |
      (?:1[0-2])
     )
     /
     (?:    # match the 1st-28th day
      0?[1-9]|1\d|2[0-8]
     )
     /
     (?:
      (?:1[6-9]|[2-9]\d)\d{2}
     )
    )$
    

    Or, if you can’t use verbose regexes in ASP.NET validators:

    ^(?:^(?:(?:(?:(?:(?:0?[13578]|1[02])/31)|(?:(?:0?[13-9]|1[0-2])/(?:29|30)))/(?:1[6-9]|[2-9]\d)\d{2})|(?:0?2/29/(?:(?:(?:1[6-9]|[2-9]\d)(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))/(?:0?[1-9]|1\d|2[0-8])/(?:(?:1[6-9]|[2-9]\d)\d{2}))$)$
    

    These allow but do not require a leading zero in single-digit months/days. If you don’t want that, replace all instances of 0? with 0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some help, I have a regular expression that appears to work just fine
I am looking for some help on creating a regular expression that would work
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
I need help with the best practice to localize asp mvc apps, I saw
I really need help with interfaces in general... Any resources that you guys would
I have a regex call that I need help with. I haven't posted my
I use ASP.NET Membership to manage users on my site. But I need to
I need help understanding some C++ operator overload statements. The class is declared like
I need help with this route map routes.MapRoute(Blog_Archive, Blog/Archive/{year}/{month}/{day}, new { controller = Blog,
I need help getting my head around the difference between my current OOP notion

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.