Hi,
I have a datepicker that I am using to increment/decrement the day by using the up/down arrow by binding the keypress event. This works fine unless the user types in a new date before leaving the datepicker and then hits the up/down arrow in which case the value() is not updated. What I want to do is upon an up/down arrow keypress, FIRST update the value() and then increment/decrement the day. How can I do this?
My js is as follows:
Thank you,
David A.
I have a datepicker that I am using to increment/decrement the day by using the up/down arrow by binding the keypress event. This works fine unless the user types in a new date before leaving the datepicker and then hits the up/down arrow in which case the value() is not updated. What I want to do is upon an up/down arrow keypress, FIRST update the value() and then increment/decrement the day. How can I do this?
My js is as follows:
$(
"#thedatePicker"
).on(
"keydown"
,
function
(e) {
var
keyCode = e.keyCode || e.which;
var
day=0;
if
(keyCode == 38) {
e.preventDefault();
day=1;
}
else
if
(keyCode == 40) {
e.preventDefault();
day=-1;
}
else
return
;
var
picker = $(
this
).data(
"kendoDatePicker"
);
// update value() here in the event the user manually typed a new date
var
dateVal = picker.value();
if
(dateVal ==
null
)
return
;
dateVal.setDate(dateVal.getDate() + day);
picker.value(dateVal);
});
Thank you,
David A.