I started by updating a new test project in MVC 4 and created a test model
public class TestModel { [Required(ErrorMessage = "The Date field is required for Start.")] [Display(Name = "Start")] public DateTime DateStart { get; set; } }
Then in my model I just got the following:
@using(Html.BeginForm()){ @Html.ValidationMessageFor(a => a.DateStart); @Html.TextBoxFor(a => a.DateStart) <input type="submit" value="add"/> }
When I delete the clear text box and click submit, I get a customized error message instead of the default value.
The Date field is required for Start.
This makes sense to me, imagine if this is a multilingual application, you definitely need to set up an error message for this country. A rocket scientist does not need to realize the need for a personalized message. And I would expect the MVC team to be covered.
source share