Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
How to use enable and disable properties together in flatpickr.js?

I am unable to use enable and disable properties together in flatpickr.js. Actually enable property is returning a range of dates that should be enabled but I want to disable specific days let's say weekends among those enabled days range.

datePickerInput.flatpickr({
                    clickOpens: false,
                    disableMobile: 'true', // Do not render mobile version UI
                    closeOnSelect: false,
                    defaultDate: null,
                    enable: [getEnableDays()],
                    disable: [
                        function (date) {
                            return (date.getDay() === 0 || date.getDay() === 6);
                        }
                    ],
                    locale: {
                        "firstDayOfWeek": 1 
                    }
                });
getEnableDays: function () {
        var me = this;
        var maxDate = '2090-12-25T16:16:22.585Z';
        var minDate = '1900-12-24T16:16:22.585Z';
        var fromDate = minDate;
        var toDate = maxDate;
        if (me.disableDays) {
            fromDate = me.isPrevDaysDisable ? me.calculatedDate.toISOString().slice(0, 10) : 'today';
            toDate = !me.isPrevDaysDisable ? me.calculatedDate.toISOString().slice(0, 10) : 'today';
        }
        return {
            from: fromDate,
            to: toDate,
        };
    },
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can't use disable along with enable but here's how you can achieve disable weekends functionality but using onDayCreate.

onDayCreate: function (dObj, dStr, fp, dayElem) {
                        if (dayElem.dateObj.getDay() === 0 || dayElem.dateObj.getDay() === 6) {
                            dayElem.className += " flatpickr-disabled nextMonthDayflatpickr-disabled";
                        }
                    },
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!