diff options
author | Keith Wood <kbwood.au@gmail.com> | 2009-12-15 04:00:17 +0000 |
---|---|---|
committer | Keith Wood <kbwood.au@gmail.com> | 2009-12-15 04:00:17 +0000 |
commit | 7c9b782ee1edbee66253dfb82d0baea1c31c5cba (patch) | |
tree | b00ec21fc1acf61ae59995a9d7b406e18fca9767 /ui/jquery.ui.datepicker.js | |
parent | 0a8392186bd9425dc77f817558547ddffb92f97d (diff) | |
download | jquery-ui-7c9b782ee1edbee66253dfb82d0baea1c31c5cba.tar.gz jquery-ui-7c9b782ee1edbee66253dfb82d0baea1c31c5cba.zip |
Datepicker: Corrected automatic parsing of date on keystrokes
Diffstat (limited to 'ui/jquery.ui.datepicker.js')
-rw-r--r-- | ui/jquery.ui.datepicker.js | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index f1c05a02a..2e191355f 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -552,18 +552,20 @@ $.extend(Datepicker.prototype, { /* Synchronise manual entry and field/alternate field. */ _doKeyUp: function(event) { var inst = $.datepicker._getInst(event.target); - try { - var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'), - (inst.input ? inst.input.val() : null), - $.datepicker._getFormatConfig(inst)); - if (date) { // only if valid - $.datepicker._setDateFromField(inst); - $.datepicker._updateAlternate(inst); - $.datepicker._updateDatepicker(inst); + if (inst.input.val() != inst.lastVal) { + try { + var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'), + (inst.input ? inst.input.val() : null), + $.datepicker._getFormatConfig(inst)); + if (date) { // only if valid + $.datepicker._setDateFromField(inst); + $.datepicker._updateAlternate(inst); + $.datepicker._updateDatepicker(inst); + } + } + catch (event) { + $.datepicker.log(event); } - } - catch (event) { - $.datepicker.log(event); } return true; }, @@ -1202,7 +1204,8 @@ $.extend(Datepicker.prototype, { /* Parse existing date and initialise date picker. */ _setDateFromField: function(inst) { var dateFormat = this._get(inst, 'dateFormat'); - var dates = inst.input ? inst.input.val() : null; + inst.lastVal = inst.input ? inst.input.val() : null; + var dates = inst.lastVal; var date, defaultDate; date = defaultDate = this._getDefaultDate(inst); var settings = this._getFormatConfig(inst); |