Community Groups are officially here!
We've released Groups, a new feature that enables us to connect community members of similar industries and interests in a shared, private space. You can check out all of the details here, including information about who can join, how to join, and what Groups are currently offered. Please leave your feedback through this Community Groups Feedback Survey.

Disabling weekends from Flatpickr

Rchriske
Rchriske Community Member Qubie ✭
edited July 29 in Custom Code

I would like disable weekends from the calendar and exclude those weekend dates when using minDate.

Example: I only want to allow people to select a date that is at least 5 business days away from the current date.

I found the code for disabling weekends on the flatpickr site but I don't where to up the code. A similar question has been asked before, but I still cannot figure out where to put it!

My current code:
Qualtrics.SurveyEngine.addOnload(function()
{

jQuery("#"+this.questionId+" input[type=text]").flatpickr({

dateFormat: "m/d/Y",
minDate:new Date().fp_incr(5)});

});

Disabling weekend code found on flatpickr

{
"disable": [
function(date) {
// return true to disable
return (date.getDay() === 0 || date.getDay() === 6);

    }
],
"locale": {
    "firstDayOfWeek": 1 // start week on Monday
}

}

Best Answer

  • dobra021
    dobra021 Community Member Guru ✭✭
    edited December 2019 Accepted Answer

    @Rchriske

    Add the following to the Header in the Look & Feel:

    Then add this to the questions JavaScript editor:

Answers

  • Flintstone81
    Flintstone81 East Lansing, MI Community Member Qubie ✭

    Do you know how to add a feature that only allows for 14 days out?

  • dobra021
    dobra021 Community Member Guru ✭✭
    edited August 3

    @Flintstone81

    add the following:

    maxDate: new Date().fp_incr(14),

  • Flintstone81
    Flintstone81 East Lansing, MI Community Member Qubie ✭

    Hi, do you know if I can get the total of two constant sums to go into a new question automatically?