Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change default validation error message in ASP.NET MVC3?

I have common issue to that How to change default validation error message in ASP.NET MVC?

I'm trying to set default validation message for all types in app but I use MVC3 and Razor engine. Unfortunately ssg solution doesn't work for me.

like image 309
Przemek Avatar asked Dec 06 '25 12:12

Przemek


2 Answers

Take a look at Model Metadata and Validation Localization using Conventions

like image 89
Eranga Avatar answered Dec 09 '25 21:12

Eranga


I know this is an old post but..

I just create C# validation code to determine if it isn't valid then return a validation message for an invalid string length.

    if (String.IsNullOrEmpty(ValidEIN))
    {
        Validation.Add("EIN",
        Validator.StringLength(0, 0, "Employee ID doesn't exist.")
        );
    }
like image 39
Ben Kauffman Avatar answered Dec 09 '25 20:12

Ben Kauffman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!