jquery
$("#Birthdate").datepicker({
dateFormat: "dd/mm/yy",
changeMonth: true,
changeYear: true,
maxDate: "+0D"
});
CSHTML
@Html.LabelFor(m => m.Birthdate)<span style="color:red;">*</span>
@Html.TextBoxFor(m => m.Birthdate, "{0:dd/MM/yyyy}", new { @class = "form-control", id = "Birthdate", style = "width: 100%;text-transform:capitalize;", placeholder = Html.DisplayNameFor(n => n.Birthdate) })
@Html.ValidationMessageFor(m => m.Birthdate)
模型
[Display(Name = "Birth Date")]
[Required(ErrorMessage = "Required!")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/mm/yyyy}", ApplyFormatInEditMode = true)]
[Column(TypeName = "date")]
public Nullable<System.DateTime> Birthdate { get; set; }
以下工作正常
从jquery datepicker中选择日期,如
03/04/2016(dd/MM/YYYY)
,然后将其保存在数据库中 比如04/03/2016(MM/dd/YYYY)
但尝试了
28/04/2016
然后显示错误请检查图片
错误
我的代码中缺少什么。 请指导我