I have tried:
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}", ConvertEmptyStringToNull = true)]
[Required(AllowEmptyStrings = true)]
public DateTime? BirthDateFrom { get; set; }
and
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
[Required]
public DateTime? BirthDateFrom { get; set; }
and all combinations with and without ConvertEmptyStringToNull and AllowEmptyStrings.
In view, I have:
@Html.EditorFor(m => m.BirthDateFrom)
I can submit form with valid date, but with empty string in that field, it just goes red and the form cannot be submitted.
How to allow HTML form submission with null or empty string value in required nullable DateTime?
It seems to me that simply removing the
[Required]annotation entirely would meet your requirement.