diff options
author | Marc Grabanski <m@marcgrabanski.com> | 2008-09-28 21:30:22 +0000 |
---|---|---|
committer | Marc Grabanski <m@marcgrabanski.com> | 2008-09-28 21:30:22 +0000 |
commit | 212a822c480c6c43d203e8d531e2d3be3da3342f (patch) | |
tree | 816c2f797511438eeab190a811624f65f87bc879 | |
parent | 46cdf1377c752b555b7d0d0c7d33dff087aadd3b (diff) | |
download | jquery-ui-212a822c480c6c43d203e8d531e2d3be3da3342f.tar.gz jquery-ui-212a822c480c6c43d203e8d531e2d3be3da3342f.zip |
Datepicker: Added option, "constrainInput" to restrict input text to the current date format.
-rw-r--r-- | ui/ui.datepicker.js | 11 |
1 files 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 = $('<div id="' + this._mainDivId + '" style="display: none;"></div>'); @@ -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. |