Setting the maxDate value for one flatpickr to the minDate of another flatpickr | XM Community
Skip to main content

Hello,
I have created a survey with two dates (start date and end date). I would like the maxDate for the end date to equal the selected start date plus 7 days. I am having a difficult time getting this to work. I don't know how to access the start and end date objects and set their min/max date values. Please see my code below.
Qualtrics.SurveyEngine.addOnReady(function()
{
//start date
jQuery("#"+this.questionId+" .InputText:first").flatpickr({
    dateFormat: "m-d-Y",
    minDate: "today",
defaultDate: "today"
});

//end date
jQuery("#"+this.questionId+" .InputText:last").flatpickr({
      dateFormat: "m-d-Y",
      minDate: "today",
    maxDate: new Date().fp_incr(7) // 7 days from today
  
});

//set the maxDate for end date to the selected start date plus 7 days.
jQuery("#"+this.questionId+" .InputText:first").on('change', function(){

var startDate = this.value;
      alert(startDate)  
});


});



Be the first to reply!

Leave a Reply