I am use DataAnnotations validation, it work perfectly but when I validate empty text box field I have error
The value '' is invalid
how can I customize this error?
p.s. error shows only when clients script are off
I am use DataAnnotations validation, it work perfectly but when I validate empty text box field I have error
The value '' is invalid
how can I customize this error?
p.s. error shows only when clients script are off
You can specify the error message in your DataAnnotations attribute. For example, take the following view model:
public class ViewModel
{
[Required(ErrorMessage = "You must enter a name")]
public string Name { get; set; }
}
When that gets validated, it will give "You must enter a name" as the error message to the user.