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

Change event does not fire on 2 digit year

3 Answers 38 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Bryan Smouse
Top achievements
Rank 1
Bryan Smouse asked on 11 Jan 2017, 08:14 PM

Hello,

I am using a date picker and have some code in the change event that I would like to fire when a date is entered into the input box.  I have found that the change event is not fired when a date is typed into the input box with a 2 digit year (17 vs 2017).  Your DatePicker/Events demo (http://demos.telerik.com/aspnet-mvc/datepicker/events) shows this behavior also.  Type in "1/1/2017" and the change event fires, clear out the box and the change event fires, type in "1/1/17" and the change event does not fire. 

Is there something I can do to make the change event fire when a date with a 2 digit year is entered?

Thanks,

Bryan Smouse

 

 

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 13 Jan 2017, 03:05 PM
Hello Bryan,

You can set a custom format and in this case the year will be read correctly. Please check out the following code snippet.
@(Html.Kendo().DatePicker()
      .Name("datepicker")
      .Format("d/M/yy")
      .Events(e =>
      {
          e.Change("change").Open("open").Close("close");
      })
     .HtmlAttributes(new { style = "width: 100%" })
)

Regards,
Kostadin
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Bryan Smouse
Top achievements
Rank 1
answered on 13 Jan 2017, 06:51 PM
Do I have to pick between a 2 digit format ("yy") or 4 digit format ("yyyy")?  Can the datepicker fire the change event for both?
0
Angel Petrov
Telerik team
answered on 17 Jan 2017, 04:23 PM
Hello,

Indeed since this format is used to parse the input you should specify it in such a manner that it matches the targeted input format.

Regards,
Angel Petrov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Date/Time Pickers
Asked by
Bryan Smouse
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Bryan Smouse
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or