Answer the question
In order to leave comments, you need to log in
How to block the necessary days in the calendar?
Good evening guys. I have a field with a datepicker. I use element-ui in the project, datepicker from here.
He has options, in this task I just use disabledDate
. My task is to block the next 7 days after the current one and block the days after a year from the current day.
First I blocked the next 7 days starting from the current day.
Here is a link to an example https://jsfiddle.net/tnrzeat0/3/
But I can’t manage to add a condition so that all subsequent days would be blocked, a year from the current day, please help
Answer the question
In order to leave comments, you need to log in
disabledDate(date) {
const currentDate = new Date();
const days7 = new Date(currentDate);
days7.setDate(currentDate.getDate() + 7);
const days7year = new Date(currentDate);
days7year.setFullYear(currentDate.getFullYear() + 1);
return (
(date.getTime() > currentDate.getTime() &&
date.getTime() < days7.getTime()) ||
date.getTime() > days7year.getTime()
);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question