0
在我的mvc 4项目中,某些模型的DateTime
属性。在客户端,我使用jquery datepicker
。我想要格式为'dd.mm.yyyy'。我的属性设置为属性不绑定模型的DateTime属性
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd.MM.yyyy}")]
[Required(AllowEmptyStrings = false, ErrorMessage = "* Field is required")]
public DateTime DateBuy { get; set; }
在* js文件我设定的日期格式:
$(".datepicker").datepicker({
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true,
dateFormat: "dd.mm.yy",
buttonImageOnly: true
});
,也是我ovverided jQuery的验证:
jQuery.validator.addMethod(
'date',
function (value, element, params) {
return value.match(/^\d\d?\.\d\d?\.\d\d\d\d$/);
},
''
);
但是,当模型来行动模型无效。错误:"The value '24.02.2013' is not valid for DateBuy."
如果日期将为02.24.2013
所有工作正常(服务器预期日期的格式为'mm.dd.yyyy')。我试过web.config
的变化文化:
<globalization culture="ru-RU" uiCulture="ru-RU" enableClientBasedCulture="true" />
你有什么想法吗?
我使用POST。我在web.config中添加了全球化标记,但它不能解决我的问题 – user571874
您可以分享视图和控制器代码吗?您正在使用<全球化文化=“RU-RU”uiCulture =“RU-RU”enableClientBasedCulture =“true”/> enableClientBasedCulture为true,使其为false或将浏览器配置为使用俄罗斯文化 –