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