From 95a6ef2f4451a395ef6bf1df4f90e2f16dea811f Mon Sep 17 00:00:00 2001 From: doublerebel Date: Sat, 20 Nov 2010 17:24:03 -0800 Subject: [PATCH] Changed _doKeyPress to limit input characters correctly based on timeFormat + a space + dateFormat (now restricts am/pm correctly based on timeFormat) --- jquery-ui-timepicker-addon.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js index b760340..75f0825 100644 --- a/jquery-ui-timepicker-addon.js +++ b/jquery-ui-timepicker-addon.js @@ -608,9 +608,14 @@ $.datepicker._doKeyPress = function(event) { if (tp_inst) { if ($.datepicker._get(inst, 'constrainInput')) { - var datetimeChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')) + "aAmMpP :", + var datetimeChars = tp_inst._defaults.timeFormat.toString() + .replace(/[hms]/g, '') + .replace(/TT|T/g, 'APM') + .replace(/tt|t/g, 'apm') + + " " + + $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')), chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode); - return event.ctrlKey || (chr < ' ' || !dateChars || dateChars.indexOf(chr) > -1); + return event.ctrlKey || (chr < ' ' || !datetimeChars || datetimeChars.indexOf(chr) > -1); } } else return $.datepicker._base_doKeyPress(event);