Javascript 如何在日期选择器中禁用输入键盘交互

Javascript 如何在日期选择器中禁用输入键盘交互,javascript,jquery,html,jquery-ui,datapicker,Javascript,Jquery,Html,Jquery Ui,Datapicker,在这里: 我明白了: 键盘交互 当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/C

在这里: 我明白了:

键盘交互

当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键必须在该字段中执行其他操作(确实如此),只是不想在该字段中设置日期。

试试这个

$(document).ready(function() {
    $("#myDate").datepicker().on("keydown", function(e){
        if (e.which == 13) {
            $("#myDate").val('');
            return false;
        }
    });
});
尝试在('keypress',函数(e){if(e.keyCode==13){return false;}}})上添加
$('.className')