2016-03-04 69 views
1

這裏如何禁用ENTER鍵盤交互: 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鍵在特定字段中不能在我的字段中設置日期。我的回車鍵必須在該字段中做其他事情(並且它),只是不希望在該字段中設置日期。

+0

嘗試添加 '$(」的className ')。在(' 按鍵,函數(E) { 如果(e.keyCode == 13){ 返回false; } });' – RRR

回答

0

試試這個,

$(document).ready(function() { 
    $("#myDate").datepicker().on("keydown", function(e){ 
     if (e.which == 13) { 
      $("#myDate").val(''); 
      return false; 
     } 
    }); 
}); 
相關問題