diff options
author | Jay Merrifield <fracmak@gmail.com> | 2012-11-13 21:07:48 -0500 |
---|---|---|
committer | Mike Sherov <mike.sherov@gmail.com> | 2012-11-13 21:08:55 -0500 |
commit | eca5abd873675f5cc7b96641c723b7e35a4260bc (patch) | |
tree | c1c05684840a278617ec6121781bb76cf7ffc278 /ui/jquery.ui.datepicker.js | |
parent | 2553d61384a89a7aa3fcea2f185c2c7ec45d2bd1 (diff) | |
download | jquery-ui-eca5abd873675f5cc7b96641c723b7e35a4260bc.tar.gz jquery-ui-eca5abd873675f5cc7b96641c723b7e35a4260bc.zip |
Datepicker: Updated the range tests so you can't navigate past the yearRange. Fixes #7362 - Datepicker allows changing year to something outside yearRange
Diffstat (limited to 'ui/jquery.ui.datepicker.js')
-rw-r--r-- | ui/jquery.ui.datepicker.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index c7ecafffb..e3c3bd398 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -1742,8 +1742,20 @@ $.extend(Datepicker.prototype, { _isInRange: function(inst, date) { var minDate = this._getMinMaxDate(inst, 'min'); var maxDate = this._getMinMaxDate(inst, 'max'); + var minYear = null; + var maxYear = null; + var years = this._get(inst, 'yearRange'); + if (years){ + var yearSplit = years.split(':'); + var currentYear = new Date().getFullYear(); + minYear = parseInt(yearSplit[0], 10) + currentYear; + maxYear = parseInt(yearSplit[1], 10) + currentYear; + } + return ((!minDate || date.getTime() >= minDate.getTime()) && - (!maxDate || date.getTime() <= maxDate.getTime())); + (!maxDate || date.getTime() <= maxDate.getTime()) && + (!minYear || date.getFullYear() >= minYear) && + (!maxYear || date.getFullYear() <= maxYear)); }, /* Provide the configuration settings for formatting/parsing. */ |