I have a problem checking the date. In my view, I have a jQuery datepicker - I changed the format from yy/mm/ddto mm/dd/yyand now I get client side validation errors. For example,
The value '02/25/2014' is not valid for Date of Birth.
Javascript:
$('#DateOfBirth').datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "mm/dd/yy",
yearRange: "-90:-5"
});
View Model:
[Required]
[Display(Name = "Date of Birth")]
public DateTime? DateOfBirth { get; set; }
View:
@Html.TextBoxFor(m=> m.DateOfBirth, "{0:MM/dd/yyyy}", new { @class = "datepicker" })
Any ideas on this?
Thanks.
UPDATE
I forgot something. Validation is not actually performed on the server side. So this has nothing to do with jQuery. ModelState.IsValid == falsefor me.
source
share