Ok I know this question has been asked, and asked, and asked, but I'm missing something and can't seem to figure it out, cause although the datepicker looks right when I try to submit a date such as 13/04/2013 the validation kicks in and says
The field [Date Due] must be a date
I've got a date Editor Template
@model DateTime?
@Html.TextBox("", (Model.HasValue ?
Model.Value.ToShortDateString() :
string.Empty), new { @class = "datepicker" })
ViewModel
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd MMM yyyy}")]
[DisplayName("Date Due")]
public DateTime? DueDate { get; set; }
and jQuery
$(document).ready(function () {
$(function () {
$(".datepicker").datepicker({ dateFormat: 'dd/mm/yy' });
});
});
The datepicker pops up when I enter a field with css class of datepicker
, I can select a date such as 13th April 2013 in the datepicker, the value shows up in the textbox but on submit fails validation.
Where am I missing something?