MVC Data Annotations DateTime Default Value

In my view model i have the following attribute:

 [DataType(DataType.Date, ErrorMessage="Please enter a valid date in the format dd/mm/yyyy")]
 [Display(Name = "Date of Birth")]
 public DateTime DOB { get; set; }

In my view i have the following:

<div class="editor-label">
    @Html.LabelFor(model => model.DOB)
<div class="editor-field">
    @Html.EditorFor(model => model.DOB)
    @Html.ValidationMessageFor(model => model.DOB)

Before submitting the form the default value for DOB is 1/01/0001 how do i stop this value being auto populated, i simply want an empty field when people visit this form?


I believe you will have to use the nullable DateTime? type. DateTime cannot be null thus it will always have a value.

Need Your Help

Fast check number to be a multiple of the big number

c++ optimization

I have a recursive algorithm that must be limited in time. If it takes too long, I am going to interrupt it. I check a time passed periodically as follows:

Cannot test JPA + Spring

java spring jpa transactions

I have the following test case: