I have:
public class StudentDto
{
[Display(Name = "Data de Nascimento")]
public DateTime? Born { get; set; }
}
I’m using jQuery datepicker, and whenever I put an invalid data, the validation message is: Please enter a valid date.
How can i change this default message?
I’ve already tried using:
[DataType(DataType.Date, ErrorMessage = @"Valor inválido")]
I’ve already tried to create a .resx, and use DefaultModelBinder.ResourceClassKey = "Strings"; , and on my .resx created values for: InvalidPropertyValue, Common_ValueNotValidForProperty, PropertyValueInvalid
None of these worked.
Thanks!
The following works fine for me:
Model:
Controller:
View:
Application_Startin Global.asax:and inside
~/App_GlobalResources/Strings.resxdefine the keyPropertyValueInvalidwhich will be used if an invalid date is entered. For the value you could use the{0}and{1}placeholders which will be replaced respectively by the value and the display name of the field.