Change event does not fire on 2 digit year

4 posts, 0 answers
  1. Bryan Smouse
    Bryan Smouse avatar
    14 posts
    Member since:
    Nov 2005

    Posted 11 Jan Link to this post

    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

     

     

  2. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 13 Jan Link to this post

    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.
  3. Bryan Smouse
    Bryan Smouse avatar
    14 posts
    Member since:
    Nov 2005

    Posted 13 Jan in reply to Kostadin Link to this post

    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?
  4. Angel Petrov
    Admin
    Angel Petrov avatar
    1026 posts

    Posted 17 Jan Link to this post

    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.
Back to Top