Closed Robelind closed 12 years ago
Try changing model year to a string and the validation error message should kick in. I'm betting the problem here is that when you use DateTime ASPNET MVC's default type checking will override any extensions and you won't get the custom error message.
Using the following model property:
[Required(ErrorMessage = "Required")] [Date(ErrorMessage = "Wrong format")] [DataType(DataType.Date)] public DateTime Date { get; set; }
With client side validation the messages "Required" and "Wrong format" are displayed as expected. With only server side validation an empty input gives the expected "Required" validation message, but wrong format gives the default "The value 'aaa' is not valid for Date.". I'd expect it to be "Wrong format".