.NET 4 MVC 2 Validation with annotations warning instead of error

Viewed 2975

I am using .NET 4 with MVC 2 for validating with Annotations. Is there a (simple) solution for giving back a warning instead of the error? So that I am able to get a green or yellow box with a message like "you should not use this content, but you may".

Big thanks in advance! :)

EDIT:
Please observe that I am already able to throw out errors via ErrorMessage but I additionally want something like WarningMessage or InfoMessage so that the user only gets a warning but might proceed. Is there a solution for this?

The Pseudocode would be: (Please note the "pseudo", because WarningMessage is (unfortunately) not a valid class)

public class Person
{
  [StringLength(50)]
  [Required(ErrorMessage = "You MUST enter a name!")]
  public string Name { get; set; }

  [Required(WarningMessage = "It is recommended to fill out the age but you may leave it out)]
  public int Age { get; set; }
}

And yes I want to have this centrallized in my validation class - not somewhere in a .js-file.

5 Answers
Related