title: Annotation Validation in Asp.net MVC just accept MM/dd/yyyy format
body: <p>I have spent several hours reading a lot of articles, but I still cannot solve my issue.</p>
  
  <p>I have a <code>DateTime</code> type property in my model:</p>
  
  <pre><code>[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
  public System.DateTime StartTime { get; set; }
  </code></pre>
  
  <p>I have set the format to <code>dd/MM/yyyy</code>, so I expect a date like 14/12/2014 to be accepted. However, the validation always fails with the message: <code>The field StartTime must be a date.</code> I tried to input 12/14/2014 and it's ok.</p>
  
  <p>Following several articles I have read, I tried to edit the format in razor code like:</p>
  
  <pre><code>@Html.TextBoxFor(model =&gt; model.StartTime, "{0:dd/MM/yyyy}")
  </code></pre>
  
  <p>And try using EditorFor like ataravati said in the below answer:</p>
  
  <pre><code>@Html.EditorFor(model =&gt; model.StartTime)
  </code></pre>
  
  <p>Or, change the culture in <code>web.config</code> to a culture in which day goes before month like GB:</p>
  
  <pre><code>&lt;system.web&gt;
      &lt;globalization uiCulture="en" culture="en-GB"/&gt;  
  &lt;/system.web&gt;
  </code></pre>
  
  <p>But, none of them work for me.</p>
  
  <p>I tried using just a text input and input the date manually (not using any control like jqueryUI). However the validation still not accept my manually input if it's in dd/MM/yyyy format.
  Could anyone show me the issue or show me the way to figure it out what the issue is?</p>
  
  <p>UPDATE:
  For someone who may have the same issue as me.</p>
  
  <p>Following the post that Stephen mentions below, we have to create a 'date' validation to overwrite the default one of annotation validation. The custom validate we create will allow the format we want.</p>
  
  <p>However, after that, the posted data to controller may not contain that data (in my case all datetime value is set to default datetime). The reason is the culture setting doesn't accept your format. We can change the culture setting in web.config but i don't think it's the best way because it can impact other value type (currency, number....) in your project. In my way, i create a custom ModelBinder for binding Datetime in the right format (an example here: <a href="http://www.codeproject.com/Articles/605595/ASP-NET-MVC-Custom-Model-Binder" rel="nofollow">http://www.codeproject.com/Articles/605595/ASP-NET-MVC-Custom-Model-Binder</a>).</p>
  
  <p>The above solution looks complicated. It shouldn't be so just for passing validation but up to now, i don't find anything better. Because of that, if someone have better solution that let annotation validation validates datetime value in format correctly, please share it.</p>