3

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.

1
  • Please elaborate and show some code which ain't working....Right now, it's impossible to understand what problems are you having Commented Jan 21, 2012 at 13:02

3 Answers 3

1

Take a look at Model Metadata and Validation Localization using Conventions

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

0

This appears to be a problem in MVC3. http://forums.asp.net/t/1512140.aspx/1/10

Here are 2 possible workarounds.

1) Write a custom validation attribute with your own error message.

2) Do it client-side. Create a custom ClientDataTypeModelValidatorProvider, how to do this with MVC2 is explained here, I haven't tried it for MVC3. There is also some good info here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.