Change message default @Html.ValidationMessageFor mvc 4

asp.net-mvc, asp.net-mvc-4, c#, razor

Solution

You can do it in your modal class's specific property using the ErrorMessage property in the of `Required` attribute.

Ex:

public class MyClass{

    [Required(ErrorMessage = "My validation error message goes here")] //give your validation message here
    [Display(Name = "My display name")] //Give your display name here
    public int NumDoc{ get; set; }
}

Problem

I try to change the message default from `@Html.ValidationMessageFor`. Where is the file who i can chage the message: `The _nameFied field is required.` View: `@Html.ValidationMessageFor(model => model.NumDoc,"", new { @class = "error-input"})`

Original source