You can improve the user experience and reduce errors by making certain dates unavailable for selection.
Minimum and maximum
Use the minimum and maximum days and time to control the two ends and reduce the available options. Let’s say you are collecting a date of birth and people have to be 13 years or older. You can simply add a max date of today - 13 years.
JS
var now = new Date();
maxDate = new Date(now.getFullYear() - 13, 11, 31);
mobiscroll.date("#date",{
max: maxDate
});
Invalids
Setting invalids helps in reducing errors. Let’s take the example of opening hours. Limit it from 9 to 5 and Monday to Friday. You can invalidate exact dates and even recurring days.
JS
mobiscroll.datetime("#datetime",{
invalid: [
'w6','w0',
{ start: '00:00', end: '09:00' },
{ start: '17:00', end: '23:59' },
],
dateWheels: '|D M d|'
});
TIP: For all the ways on how you can pass invalids check out the API docs.
What's next?
Formatting values and special use cases: Continue by overriding the date and time format and use the controls for things like capturing credit card expiration dates.
Start a free trial: Get started with the Date & Time control by starting a free trial.