D
D
Dima Pautov2018-03-06 17:55:05
Vue.js
Dima Pautov, 2018-03-06 17:55:05

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

1 answer(s)
A
akass, 2018-03-06
@bootd

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()
          );
        }

If I understand you correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question