Im facing this error when im using my jQuery datepicker.
jQuery:
$( ".datepicker" ).datepicker({
defaultDate: +7,
autoSize: true,
dateFormat: 'dd.mm.yy',
});
Model:
[DisplayName("Date")]
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
[Required(ErrorMessage = "Date is required")]
public DateTime Date { get; set; }
So I want the date format to be like dd.MM.yyyy
, and when I select the date using the datepicker it is correctly added to the field. But also in the same second, an validation error appears saying The field 'Date' must be a date
.
I did test with writing manually the date in the format dd/MM/yy
and then it looks like it is working. So somewhere the validator looks for that format, but I cant find out where to modify it.