From 212a822c480c6c43d203e8d531e2d3be3da3342f Mon Sep 17 00:00:00 2001 From: Marc Grabanski Date: Sun, 28 Sep 2008 21:30:22 +0000 Subject: Datepicker: Added option, "constrainInput" to restrict input text to the current date format. --- ui/ui.datepicker.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ui/ui.datepicker.js b/ui/ui.datepicker.js index 32aef0721..1d3a168c3 100644 --- a/ui/ui.datepicker.js +++ b/ui/ui.datepicker.js @@ -124,7 +124,8 @@ function Datepicker() { rangeSelect: false, // Allows for selecting a date range on one date picker rangeSeparator: ' - ', // Text between two dates in a range altField: '', // Selector for an alternate field to store selected dates into - altFormat: '' // The date format to use for the alternate field + altFormat: '', // The date format to use for the alternate field + constrainInput: true // The input is constrained by the current date format }; $.extend(this._defaults, this.regional['']); this.dpDiv = $(''); @@ -520,9 +521,11 @@ $.extend(Datepicker.prototype, { /* Filter entered characters - based on date format. */ _doKeyPress: function(e) { var inst = $.datepicker._getInst(e.target); - var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')); - var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode); - return e.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1); + if ($.datepicker._get(inst, 'constrainInput')) { + var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')); + var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode); + return e.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1); + } }, /* Pop-up the date picker for a given input field. -- cgit v1.2.3