If I use EditFor in MVC my DateTime field show a not formated datetime, If I use a old school html my field don't receive the error class.
<div class="editor-field"> <input type="text" name="EstimateTime" id="EstimateTime" value="<%: (Model != null) ? Model.EstimateTime.ToString("dd/MM/yyyy hh:mm:ss tt") : "" %>" /> <%: Html.TextBoxFor(model => model.EstimateTime, new { @value = (Model != null) ? Model.EstimateTime.ToString("dd/MM/yyyy hh:mm:ss tt") : "" })%> <%: Html.ValidationMessageFor(model => model.EstimateTime) %> </div> result HTML: Look the difference between the value:
<div class="editor-field"> <input type="text" name="EstimateTime" id="EstimateTime" value="31/10/2013 01:54:42 PM" class="hasDatepicker"> <input id="EstimateTime" name="EstimateTime" type="text" value="10/31/2013 1:54:42 PM" class="input-validation-error text-box single-line"> <span class="field-validation-error">Isn't a date/time valid</span> </div> What is the best practices to fix it?