Possible Duplicate:
ASP.net MVC - Custom attribut error message with nullable properties
Can I replace default validation message for integer field? I want to localize it. (For int: "The field Id must be a number.")
Possible Duplicate:
ASP.net MVC - Custom attribut error message with nullable properties
Can I replace default validation message for integer field? I want to localize it. (For int: "The field Id must be a number.")
You could use the ErrorMessageResourceName property:
[Required(ErrorMessageResourceName = "SomeResource")]
[StringLength(30, ErrorMessageResourceName = "SomeOtherResource")]
public string Name { get; set; }
You may checkout this blog post for an example.
In response to this
How can I apply it for integer validation?
Firstly how are you validating integers ? Show us some code.
If your are using Regular expressions then use
[RegularExpression("pattern", ErrorMessageResourceName = "SomeResource")]
or if you are using a custom attribute, you can use this in similar fashion.