title: MVC Validation to accept DateTime in ddMMyyyy format
body: <p>I just want to accept Date in ddMMyyyy format while submiting. But its gives an error like</p>
  
  <blockquote>
    <p>The field FromDate must be a date.</p>
  </blockquote>
  
  <p><img src="https://i.stack.imgur.com/JVr8s.png" alt="enter image description here"></p>
  
  <p>But, When I put date in MMddyyyy it accepts pkkttrfg roperly. <br>
  My Model is </p>
  
  <pre><code>public class CompareModel 
  {
      [Required]
      [DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}", ApplyFormatInEditMode = true)]
      public DateTime FromDate { get; set; }
  
      [Required]
      [DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}", ApplyFormatInEditMode = true)]
      public DateTime TODate { get; set; }
  
  }
  </code></pre>
  
  <p>My View Part is</p>
  
  <pre><code>&lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.FromDate, new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.EditorFor(model =&gt; model.FromDate)
              @Html.ValidationMessageFor(model =&gt; model.FromDate)
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.TODate, new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.EditorFor(model =&gt; model.TODate)
              @Html.ValidationMessageFor(model =&gt; model.TODate)
          &lt;/div&gt;
      &lt;/div&gt;
  
  
      &lt;div class="form-group"&gt;
          &lt;div class="col-md-offset-2 col-md-10"&gt;
              &lt;input type="submit" value="Create" class="btn btn-default" /&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>