views:

79

answers:

0

We are using MVC Validation Model to do both client and server validation. On the client side, we are using jQuery. Everything works great except the jQuery that is produced to validate a date range. We are always getting the error message displayed that says the date entered is not within the range. Here is what I have:

Relevant Model Code:

[DisplayName("Date Posted")]
[Range(typeof(DateTime), "01/01/2000", "01/01/2050", ErrorMessage = "{0} should be between {1:d} and {2:d}")]
public DateTime PostedDate { get; set; }

Relevant View Code:

...

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&gt;&lt;/script&gt;
<script src="<%= Url.Content("~/Scripts/jquery.validate.js") %>" type="text/javascript"></script>
<script src="<%= Url.Content("~/Scripts/MicrosoftMvcJQueryValidation.js") %>" type="text/javascript"></script>

...

<% Html.EnableClientValidation(); %>

...

<%: Html.ValidationMessageFor(model => model.PostedDate) %>

...