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

  • SEARCH
  • Home
  • 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 8021827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:06:11+00:00 2026-06-04T22:06:11+00:00

I have an Entity Frameworks POCO that has a property defined like this: [RegularExpression(ValidationHelper.RegularExpressionForDateOnly)]

  • 0

I have an Entity Frameworks POCO that has a property defined like this:

[RegularExpression(ValidationHelper.RegularExpressionForDateOnly)]
public virtual DateTime LastBuildDate { get; set; }

Where the constant is defined like this:

public const String RegularExpressionForDateOnly = 
    @"^(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:0?2(\/|-|\.)29\3(?:(?:(?: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])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$";

I got that regex right from OWASP: https://www.owasp.org/index.php/OWASP_Validation_Regex_Repository

Now, on the MVC3 view, I have:

<tr>
<td class="editor-label">
    @Html.LabelFor(model => model.LastBuildDate)
</td>
<td class="editor-field">
    @Html.EditorFor(model => model.LastBuildDate)
    @Html.ValidationMessageFor(model => model.LastBuildDate)
</td>
</tr>

When I try to put a date in the format of “05/30/2012” or “5/30/2012”, it fails validation (client and server-side). If I manually try that regular expression, that regular expression SHOULD allow those formats. However, when the MVC3 view is validating with it, it fails validation.

What other reason would there be for the MVC to fail this regex validation?

  • 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-06-04T22:06:12+00:00Added an answer on June 4, 2026 at 10:06 pm

    I dont know enough about regex to tell you exactly what your doing wrong, but when it comes to MVC3 validators, I definitely recommend the Data Annotations Extension you can find it on Nuget too.
    It adds a bunch of validation attributes including date validation.

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

Sidebar

Related Questions

I have an Entity Framework Entity that looks something like this: class ListItemEtlObject {
I have an Entity in Code First Entity framework that currently looks like this:
I have an Entity Framework POCO class that is generated by a T4 Template.
I have a SQL Server DB table that has a column ReceivedDate defined as
I am attempting to use Entity Framework and have a contact database that has
I have the following Entity Framework POCO classes: public class Customer { public int
I have been using the Entity Framework with the POCO First approach. I have
I have converted an Entity framework project to use POCO objects by removing the
We have an entity framework model with has some inheritance in it. The following
I have an Entity Framework generated table with values in a td that I

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.