My model has a property like this:
[Display(Name = "Date of Service")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)] // ISO compliance for jQuery validation
[SqlDateRange] // Enforces min/max SQL DateTime values (also handles nulls caused by invalid dates like "12/01/19900" -- I suppose the issue could be resolved by finding a better way of handling that null case
public DateTime? DateOfService { get; set; }
But when I use this in my view,
@Html.EditorFor(model => model.Date)
I get this, which gets passed as null. I'm already checking for null
via an attribute because the editor also allows hugely invalid dates like 12/12/21390 -- which also pass as null
.
Edit: I'm using Chrome.