How to enable certain dates in flatpickr

672 Views Asked by At

I want to show only available dates in calendar when the onChange method is clicked.

My code so far:

$("#test").flatpickr({
    enableTime: false,
    defaultDate: ["<?php echo date("Y-m-d"); ?>"],
    disable: ["2021-01-01", "2021-01-02"],
    locale: {
        "firstDayOfWeek": 1 // start week on Monday
    },
    onChange: function(selectedDates, dateStr, instance) {
        instance.set('disable', true);

       instance.set('enable', ["2021-01-04","2021-01-05"]);
    },
});

I can't seem to disable all the dates, and just show the ones set to enabled, ideas?

0

There are 0 best solutions below