I use Asp.Net Core MVC (Razor + Jquery Validate + Unobtrusive). I display in a Datepicker only the date part of a DateTime field through the following code in my ViewModel:
[Required(ErrorMessage = "* preenchimento obrigatório")]
[DataType(DataType.Date)]
public DateTime Data { get; set; } = DateTime.Now;
However, in my view, typing the contents of the field with a valid date, I get the error message "Please enter a valid date."
When you remove the data annotation [DataType (DataType.Date)] and the time share is displayed, the validation works correctly, so is not a localization problem p>
I have also added the following annotation date to ViewModel, but I did not succeed:
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
I'm not sure, but from what I think the problem is in unobtrusive validation that does not seem to behave right with inputs that only display part of the date.
How do I solve this problem?