DatePicker value modification using numpad keys and Romanian keyboard layout

Thread is closed for posting
1 posts, 0 answers
  1. 946156B3-68B7-4627-B2DE-9DA6B7C50CA3
    946156B3-68B7-4627-B2DE-9DA6B7C50CA3 avatar
    2 posts
    Member since:
    Jan 2010

    Posted 18 Nov 2016 Link to this post

    Requirements

    Telerik Product and Version

    Kendo UI Complete version 2016.3 1118

    Supported Browsers and Platforms

    Google Chrome, Windows 10 64 bit

    Components/Widgets used (JS frameworks, etc.)

    DatePicker

    PROJECT DESCRIPTION

    In Windows OS when the user change keyboard layout language to Romanian, numpad  key "." (dot) is changed to "," (comma).

    So, In order to change the value of a DatePicker control using numpad keys, including the separator (now is ","), I changed "," character from the input element text value with "." on blur event  (when control loses the focus). The text value is converted to a date variable using the same format as for the control. At the end the control value is changed with that date value.

    $("#zi").kendoDatePicker({
      value: new Date(),
      format: 'dd.MM.yyyy'
      });
     
    $("#zi").on('blur', function() {
      var pk = $(this).data("kendoDatePicker");
     
      var val = pk.element.val();
     
      if(val.indexOf(',') != -1) {
        val = val.replace(/,/g,'.');
        pk.value(kendo.parseDate(val,pk.options.format));
      }
     
      pk.trigger("change");
     
      $("#log_zi").html(pk.value());
    });

    DEMO: http://dojo.telerik.com/ASOSO/6 

    Alternatively, user keyboard input can be intercepted, and manipulated accordingly.

    DEMO:  http://dojo.telerik.com/ASOSO/7

Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.