aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2010-11-22 12:59:57 -0500
committerScott González <scott.gonzalez@gmail.com>2010-11-22 12:59:57 -0500
commit9ade71071a54fba328a429e608757e8d984b052e (patch)
tree9bad52854c2762ee64ec097ddb37a67e22bd6d7c /ui
parent7b523c2ec144fb0f4e39ad1c593453058fd3fb3a (diff)
downloadjquery-ui-9ade71071a54fba328a429e608757e8d984b052e.tar.gz
jquery-ui-9ade71071a54fba328a429e608757e8d984b052e.zip
Datepicker: Proper handling of empty strings for dates.
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.datepicker.js9
1 files changed, 3 insertions, 6 deletions
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index 687ed2b05..ed2ab0600 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -1316,7 +1316,7 @@ $.extend(Datepicker.prototype, {
}
return new Date(year, month, day);
};
- var newDate = (date == null ? defaultDate : (typeof date == 'string' ? offsetString(date) :
+ var newDate = (date == null || date === '' ? defaultDate : (typeof date == 'string' ? offsetString(date) :
(typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate);
if (newDate) {
@@ -1342,10 +1342,7 @@ $.extend(Datepicker.prototype, {
/* Set the date(s) directly. */
_setDate: function(inst, date, noChange) {
- if ( !date ) {
- inst.input.val( "" );
- return;
- }
+ var clear = !date;
var origMonth = inst.selectedMonth;
var origYear = inst.selectedYear;
var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
@@ -1356,7 +1353,7 @@ $.extend(Datepicker.prototype, {
this._notifyChange(inst);
this._adjustInstDate(inst);
if (inst.input) {
- inst.input.val(this._formatDate(inst));
+ inst.input.val(clear ? '' : this._formatDate(inst));
}
},