Restrictions allow you to prevent users from selected dates or times based on a set of rules.
new tempusDominus.TempusDominus(document.getElementById('datetimepicker1'),
{
restrictions: {
minDate: undefined,
maxDate: undefined,
disabledDates: [],
enabledDates: [],
daysOfWeekDisabled: [],
disabledTimeIntervals: [],
disabledHours: [],
enabledHours: []
}
}
)
Accepts: string | Date | DateTime Defaults: undefined
Prevents the user from selecting a date/time before this value. Set to
undefined
to remove
the
restriction.
Throws conflictingConfiguration if value is after maxDate.
Accepts: string | Date | DateTime Defaults: undefined
Prevents the user from selecting a date/time after this value. Set to undefined
to remove the
restriction.
Throws conflictingConfiguration if value is after maxDate.
Allows the user to select only from the provided days. Setting this takes precedence over options.minDate, options.maxDate configuration.
Disallows the user to select any of the provided days. Setting this takes precedence over options.minDate, options.maxDate configuration.
Throws numbersOutOfRage any value is not between 0-23
Allows the user to select only from the provided hours.
Disallows the user to select any of the provided hours.
Accepts: array of an object with from: DateTime, to: DateTime
Defaults:
undefined
Disables time selection between the given DateTimes.
const later = new tempusDominus.DateTime();
later.hours = 8;
new tempusDominus.TempusDominus(..., {
restrictions: {
disabledTimeIntervals: [
{ from: new tempusDominus.DateTime().startOf('date'), to: later }
]
}
});
Accepts: array of numbers from 0-6
Disallow the user to select weekdays that exist in this array. This has lower priority over the
options.minDate, options.maxDate, options.disabledDates and options.enabledDates configuration
settings.
Throws numbersOutOfRage any value is not between 0-6.