This is a migrated thread and some comments may be shown as answers.

Date format error with date picker

1 Answer 608 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Raja
Top achievements
Rank 1
Raja asked on 30 Jun 2015, 04:39 PM

I am getting a warning in the browser console (Chrome) with kendo date picker.

 

I am not setting date format to "yyyy-MM-dd". I have even tried to set up date format in the cshtml page for the kendo date picker.

@(Html.Kendo().DatePickerFor(m => m.StartDate)
           .Name("StartDate")
           .Format("MM/dd/yyyy")
           .Value(Model.StartDate))

Is this a default date format with date pciker? How can I change it?

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 02 Jul 2015, 11:05 AM
Hello Raja,

The described warning is due the validation that Chrome performs. It does allow only one specific format / value *yyyy-MM-dd" to put in when the input is of type "date". In general, we generate an input element with type "date" and then on the client we change it to type="text" in order to allow different formatted values (e.g. MM/dd/yyyy).

If you would like to avoid the warnings, just set the type of the input explicitly to "text":
@(Html.Kendo().DatePickerFor(m => m.StartDate)
           .Name("StartDate")
           .HtmlAttributes(new { type = "text" })
           .Format("MM/dd/yyyy")
           .Value(Model.StartDate))

The side effect of this action is that the input will not be of date type if JavaScript is disabled (graceful degradation).

Regards,
Georgi Krustev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Date/Time Pickers
Asked by
Raja
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or