2

在这里: http ://api.jqueryui.com/datepicker/ 我看到:

键盘交互

当日期选择器打开时,可以使用以下键盘命令:

PAGE UP: Move to the previous month.
PAGE DOWN: Move to the next month.
CTRL + PAGE UP: Move to the previous year.
CTRL + PAGE DOWN: Move to the next year.
CTRL + HOME: Open the datepicker if closed.
CTRL/COMMAND + HOME: Move to the current month.
CTRL/COMMAND + LEFT: Move to the previous day.
CTRL/COMMAND + RIGHT: Move to the next day.
CTRL/COMMAND + UP: Move to the previous week.
CTRL/COMMAND + DOWN: Move the next week.
ENTER: Select the focused date.
CTRL/COMMAND + END: Close the datepicker and erase the date.
ESCAPE: Close the datepicker without selection.

我不想要:

ENTER:选择焦点日期。

相互作用

是否可以禁用单个交互?我在特定字段中的 Enter 键不得在我的字段中设置日期。我的 Enter 键必须在该字段中执行其他操作(确实如此),只是不想在该字段中设置日期。

4

1 回答 1

0

尝试这个,

$(document).ready(function() {
    $("#myDate").datepicker().on("keydown", function(e){
        if (e.which == 13) {
            $("#myDate").val('');
            return false;
        }
    });
});
于 2016-03-04T11:54:14.360 回答