ASP.NET MVC 4避免产生数据-VAL-日期日期时间 [英] ASP.NET MVC 4 avoid generation of data-val-date for datetime
问题描述
我怎么能避免HTML属性数据-VAL-日期的产生从一个日期时间属性创建元素?
how can I avoid the generation of the html attribute "data-val-date" for the element created from a Datetime property?
模型:
public class RegisterModel
{
[Required]
[Display(Name = "Date of birth")]
public DateTime? DateOfBirth { get; set; }
}
视图:
@Html.LabelFor(m => m.DateOfBirth)
@Html.EditorFor(m => m.DateOfBirth)
其实,我创建了三下拉列表元素选择诞生之日起,不给日期格式的值。
我见过一些解决方案,包括在周围的工作:删除与一个JavaScript验证。
我设想的解决方案是日期时间属性分成三个长一个用于每个值(日,月,年)。
In fact, I'm creating a three drop down lists element for selecting the date of birth, which don't give a value in a date format. Some solutions I've seen, consisted in a work around: removing the validation with a javascript. The solution I envisage is to split the DateTime property into three long one for each value (day, month, year).
推荐答案
数据-VAL-日期所使用的验证系统来验证的日期。如果你删除它,客户端验证将无法正常工作。
data-val-date is used by the validation system to validate the date. If you remove it, client-side validation won't work.
如果这就是你想要的东西,那么就禁用客户端验证。
If that's what you want, then just disable client-side validation.
这篇关于ASP.NET MVC 4避免产生数据-VAL-日期日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!