Disabling weekends from Flatpickr | XM Community
Solved

Disabling weekends from Flatpickr

  • 3 December 2019
  • 5 replies
  • 630 views

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
}
}
icon

Best answer by dobra021 6 December 2019, 18:12

View original

5 replies

Userlevel 5
Badge +36
@Rchriske

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

Then add this to the questions JavaScript editor:
!
@dobra021 , you are amazing! I can't tell you how long I've been working on this issue. I wish I would have asked sooner. THANK YOU!!!!!
Userlevel 1
Badge +2

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

Userlevel 5
Badge +36

Flintstone81
add the following:
maxDate: new Date().fp_incr(14),


Userlevel 1
Badge +2

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

image.png

Leave a Reply