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