Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change message default @Html.ValidationMessageFor mvc 4

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"})

like image 768
CesarMiguel Avatar asked Mar 22 '23 13:03

CesarMiguel


1 Answers

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; }
}
like image 57
PSL Avatar answered Mar 24 '23 04:03

PSL