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

Setting up DateInput messages in DatePicker?

2 Answers 550 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Luc
Top achievements
Rank 1
Luc asked on 28 Nov 2017, 04:26 PM

Hello,

I'm trying to setup a specific display format for a DatePicker when using DateInput. The following works fine functionally:

@(Html.Kendo().DatePicker()
.Format("yyyy-MM-dd")
.DateInput()
.Name("dpSitOpenDate")
.HtmlAttributes(new { style = "width:90%"})
)

 

My issue with this is that when DateInput() is active, it displays: "Year-Month-Day" before any date is entered. I would prefer it to show "yyyy-mm-dd" instead, so that users know exactly what format is expected of them before they start typing.

 

I know that a DateInput control by itself has the possibility to enter custom Messages which I believe would have the effect I want, as explained in the Localization example of this page:

https://docs.telerik.com/kendo-ui/controls/editors/dateinput/overview

 

Is it possible to setup those messages on the DateInput that is embedded in the DatePicker? The only parameter that can seemingly be passed to .DateInput() is a Boolean, so I'm not sure how I could set those messages during creation, and I'm not sure how I would access the DateInput via script either. I know I can access the DatePicker itself via $("#dpSitOpenDate").data("kendoDatePicker") for example, but not the DateInput within it.

 

Thank you!

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi
Telerik team
answered on 30 Nov 2017, 12:14 PM
Hello Luc,

A possible solution is to set the messages of the dateInput using the setOptions method

e.g.
$('#datePicker').data('kendoDatePicker')._dateInput.setOptions({
    messages:{
      "year": "yyyy",
      "month": "mm",
      "day": "dd"
    }
  })

In the link below you will find a dojo sample which demonstrates the above solution:



Regards,
Georgi
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Luc
Top achievements
Rank 1
answered on 30 Nov 2017, 12:22 PM

Wonderful! That was exactly what I was looking for.

I was aware of the setOptions method that you could use on a dateInput, but not that you could access the dateInput within the datePicker by using ._dateInput

Thank you very much!

Tags
Date/Time Pickers
Asked by
Luc
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Luc
Top achievements
Rank 1
Share this question
or