I have a Asp.Net web app and I have the following date defined in my model:
[Required]
[Display(Name = "Birth Date")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:MMM-dd-yyyy}", ApplyFormatInEditMode = true)]
[RegularExpression(@"(((0[1-9]|1[0-2])\/(0|1)[0-9]|2[0-9]|3[0-1])\/((19|20)\d\d))$", ErrorMessage = "Invalid date format.")]
public DateTime BirthDate { get; set; }
When the viewis retrieved, the birth date set to the field from the database is: 1/18/1985 12:00:00 am
I change it to: 01/18/1985 and submit the Form.
The controller server-side validation catches it as an error - invalid date format.
What am I doing wrong?

Jignesh KumarRank #91 · 22.9K reputationPosted Mar 30, 2020, 8:08 AM EDT
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Mar 30, 2020, 8:13 PM EDT
Vinay SinghRank #604 · 4K reputationPosted Mar 30, 2020, 9:28 PM EDT
@Html.TextBoxFor(m => m.ProcedureEffectiveFrom, "{0:MM dd, yyyy}" new { @class = "form-control date-picker" })