Reputation: 13162
I use vuetify datepicker and moment js
I want to disable sunday on datepicker
My code like this :
<v-date-picker
v-model="date"
:allowed-dates="allowedDates"
class="mt-4"
:min="currentDate"
@update:picker-date="pickerUpdate($event)"
></v-date-picker>
My full code and codepen like this : https://codepen.io/positivethinking639/pen/qBBjaJr?editors=1010
How can I do it?
So I want to disable all Sundays in October, November and December
Upvotes: 0
Views: 5209
Reputation: 57
Vue Datepicker have a build in filter to filter out or disable specific week day
0 bein Sunday 6 being Saturday
<template>
<VueDatePicker v-model="date" :disabled-week-days="[6, 0]" />
</template>
Upvotes: 1
Reputation: 19
I would just do simple check which day it is with either dayjs
or moment
allowedDates(val) {
return dayjs(val).day() !== 0;
},
Upvotes: 1
Reputation: 214927
One obvious solution is to check the day of week before pushing the date to available dates:
if (moment(date).day() !== 0)
availableDates.push(date)
https://codepen.io/leopsidom/pen/poowNjJ?editors=1011
Upvotes: 3