mirror of
https://github.com/xdan/datetimepicker.git
synced 2024-11-18 06:24:22 +00:00
Allow blank values if 'options.allowBlank' is set
This commit is contained in:
parent
26378d3402
commit
630ab13931
@ -1278,8 +1278,20 @@
|
|||||||
return !isNaN(d.getTime());
|
return !isNaN(d.getTime());
|
||||||
};
|
};
|
||||||
|
|
||||||
_this.setCurrentTime = function (dTime) {
|
_this.setCurrentTime = function (dTime, requireValidDate) {
|
||||||
_this.currentTime = (typeof dTime === 'string') ? _this.strToDateTime(dTime) : _this.isValidDate(dTime) ? dTime : _this.now();
|
if (typeof dTime === 'string') {
|
||||||
|
_this.currentTime = _this.strToDateTime(dTime);
|
||||||
|
}
|
||||||
|
else if (_this.isValidDate(dTime)) {
|
||||||
|
_this.currentTime = dTime;
|
||||||
|
}
|
||||||
|
else if (!dTime && !requireValidDate && options.allowBlank) {
|
||||||
|
_this.currentTime = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_this.currentTime = _this.now();
|
||||||
|
}
|
||||||
|
|
||||||
datetimepicker.trigger('xchange.xdsoft');
|
datetimepicker.trigger('xchange.xdsoft');
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1529,6 +1541,10 @@
|
|||||||
xchangeTimer = setTimeout(function () {
|
xchangeTimer = setTimeout(function () {
|
||||||
|
|
||||||
if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
|
if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
|
||||||
|
//In case blanks are allowed, delay construction until we have a valid date
|
||||||
|
if (options.allowBlank)
|
||||||
|
return;
|
||||||
|
|
||||||
_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
|
_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2254,7 +2270,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
triggerAfterOpen = true;
|
triggerAfterOpen = true;
|
||||||
_xdsoft_datetime.setCurrentTime(getCurrentValue());
|
_xdsoft_datetime.setCurrentTime(getCurrentValue(), true);
|
||||||
if(options.mask) {
|
if(options.mask) {
|
||||||
setMask(options);
|
setMask(options);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user