【发布时间】:2012-12-10 19:16:45
【问题描述】:
我正在开发一个 ASP.NET MVC4 应用程序。
我的视图模型类属性
[DisplayName("Birth Date")]
[Required(ErrorMessage = "You must indicate your full birthday")]
[DataType(DataType.Date), DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime BirthDate { get; set; }
Javascript 代码
var dt = new Date();
$(function () {
$("#BirthDate").datepicker({
showOn: "button",
buttonImage: "@Url.Content("~/Content/themes/base/images/calendar.gif")",
buttonImageOnly: true,
dateFormat: 'dd/mm/yy',
changeMonth: true,
changeYear: true,
yearRange: '1980:dt'
});
});
查看代码
<div class="block">
@Html.LabelFor(model => model.BirthDate, new { @Class = "compel" })
@Html.TextBoxFor(model => model.BirthDate)
</div>
当我在 IE 和 Mozilla Firefox 中运行该应用程序时,它运行良好,但使用 google chrome 时,它会给出验证错误,因为 24/12/2012 的值对于出生日期无效。
请帮我解决这个问题。
【问题讨论】:
标签: google-chrome localization asp.net-mvc-4 jquery-validate date-format