我使用 MVC 5,在我的模型中我有这样的 DateTime 属性:
[Column(TypeName = "Date")]
[DataType(DataType.Date)]
public DateTime StartDate { get; set; }
当我输入无效日期时,ValidationSummary 中会出现以下消息:
The field StartDate must be a date
我需要在可以更改的地方更改此消息?
请您参考如下方法:
您需要添加 ErrorMessage 属性。试试这个
[DataType(DataType.Date),ErrorMessage="Your message here"]
