I am using the flatpickr calendar. It supports various functions for enabling/disabling dates, but I can't seem to get both enabling and disabling to work simultaneously.
I am trying to disable Sundays and and also disable all dates in the future (counted from a date I generate using PHP).
Disabling Sundays did work before I added the second function to only enable dates in the past, incl. today.
Here is the code:
"enable": [
function(date) {
// return true to enable
return (date.getDate() <= <?php echo $nextDateAllowed; ?>);
}
],
"disable": [
function(date) {
// return true to disable
return (date.getDay() === 0);
}
],
locale: {
firstDayOfWeek: 1
}
Thinking this could be because of the order of the functions, I swapped them (disable
was first, enable
was second), but when I open the calendar, the previous Sunday is still active.
Hope you can help.
you can use only enable like this
"enable": [
function(date) {
// return true to enable
return (date.getDate() <= <?php echo $nextDateAllowed; ?> && date.getDay() !== 0 );
}
]
work fine for me :D