mirror of
https://github.com/xdan/datetimepicker.git
synced 2024-11-18 06:24:22 +00:00
add feature allow date by regex
This commit is contained in:
parent
d6ffe92124
commit
7178b48c30
@ -597,6 +597,7 @@
|
||||
highlightedDates: [],
|
||||
highlightedPeriods: [],
|
||||
allowDates : [],
|
||||
allowDateRe : null,
|
||||
disabledDates : [],
|
||||
disabledWeekDays: [],
|
||||
yearOffset: 0,
|
||||
@ -1054,6 +1055,10 @@
|
||||
if (_options.allowDates && $.isArray(_options.allowDates) && _options.allowDates.length) {
|
||||
options.allowDates = $.extend(true, [], _options.allowDates);
|
||||
}
|
||||
|
||||
if (_options.allowDateRe && Object.prototype.toString.call(_options.allowDateRe)==="[object String]") {
|
||||
options.allowDateRe = new RegExp(_options.allowDateRe);
|
||||
}
|
||||
|
||||
if (_options.highlightedDates && $.isArray(_options.highlightedDates) && _options.highlightedDates.length) {
|
||||
$.each(_options.highlightedDates, function (index, value) {
|
||||
@ -1665,7 +1670,11 @@
|
||||
customDateSettings = null;
|
||||
}
|
||||
|
||||
if(options.allowDates&&options.allowDates.length>0){
|
||||
if(options.allowDateRe && Object.prototype.toString.call(options.allowDateRe) === "[object RegExp]"){
|
||||
if(!options.allowDateRe.test(start.dateFormat(options.formatDate))){
|
||||
classes.push('xdsoft_disabled');
|
||||
}
|
||||
} else if(options.allowDates && options.allowDates.length>0){
|
||||
if(options.allowDates.indexOf(start.dateFormat(options.formatDate)) === -1){
|
||||
classes.push('xdsoft_disabled');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user