From daa38f5ef3e3dc583a04ca881203e9988124e171 Mon Sep 17 00:00:00 2001 From: Alexander Gitter Date: Sat, 11 Jun 2011 05:49:56 +0200 Subject: [PATCH] Fix issue #177, keyboard input not working when datepicker wants us to accept all characters --- jquery-ui-timepicker-addon.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js index 191e2ac..a41dbd4 100644 --- a/jquery-ui-timepicker-addon.js +++ b/jquery-ui-timepicker-addon.js @@ -804,7 +804,7 @@ $.datepicker._updateDatepicker = function(inst) { }; //####################################################################################### -// third bad hack :/ override datepicker so it allows spaces and colan in the input field +// third bad hack :/ override datepicker so it allows spaces and colon in the input field //####################################################################################### $.datepicker._base_doKeyPress = $.datepicker._doKeyPress; $.datepicker._doKeyPress = function(event) { @@ -814,6 +814,7 @@ $.datepicker._doKeyPress = function(event) { if (tp_inst) { if ($.datepicker._get(inst, 'constrainInput')) { var ampm = tp_inst._defaults.ampm, + dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')), datetimeChars = tp_inst._defaults.timeFormat.toString() .replace(/[hms]/g, '') .replace(/TT/g, ampm ? 'APM' : '') @@ -825,9 +826,9 @@ $.datepicker._doKeyPress = function(event) { " " + tp_inst._defaults.separator + tp_inst._defaults.timeSuffix + - $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')), + dateChars, chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode); - return event.ctrlKey || (chr < ' ' || !datetimeChars || datetimeChars.indexOf(chr) > -1); + return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1); } }