The field must be a date - DatePicker validation fails in Chrome - mvc The field must be a date - DatePicker validation fails in Chrome - mvc google-chrome google-chrome

The field must be a date - DatePicker validation fails in Chrome - mvc


Exact the same situation here (partial view)

I solved it by removing the validation attribute and perform validation at server side:

$('#date').removeAttr("data-val-date");


In my opinion problems is that MVC is generating for date HTML5 input with [type=date]. This causes that in chrome valid date format is same same as system date format.

You can probably set date format in MVC to be common with JqueryUI using following attribute:

[DataType(DataType.Date), DisplayFormat( DataFormatString="{0:dd.MM.yy}", ApplyFormatInEditMode=true )]

The second idea is to use code from article: Creating a Native HTML 5 Datepicker with a Fallback to jQuery UI

One more thing. There is a good topic about date in html input: Is there any way to change input type="date" format?


I solved it by removing the validation attribute

@model Pro.Web.Models.Model<div class="editor-field">@{ Html.EnableClientValidation(false); }@Html.TextBoxFor(model => model.Item.Date, new { @class = "picker" })@Html.ValidationMessageFor(model => model.Item.Date)@{ Html.EnableClientValidation(true); }