Modify Calendar to only show 12 months past current date | XM Community
Skip to main content

I’ve been searching for a way to show a calendar to respondents that only allows them to select a date within the previous 12 months of the current date. Anything past 12 months would not appear for them. If this isn’t possible, we could also have a custom prompt that closes the survey if they were to pick a date from say, 13 or 14 months ago (from current date). 

 

I would greatly appreciate any help. Thank you!

flatpickr has options to accomplish your requirements.  Search the Community for implementation details.


Qualtrics.SurveyEngine.addOnload(function()
{
    jQuery("#"+this.questionId+" .InputText").flatpickr({altInput: true, altFormat: "m-d-Y", dateFormat: "m-d-Y", minDate:"07-01-2022", maxDate: "12-31-2022"});
});

Qualtrics.SurveyEngine.addOnReady(function()
{
    /*Place your JavaScript here to run when the page is fully displayed*/

});

Qualtrics.SurveyEngine.addOnUnload(function()
{
    /*Place your JavaScript here to run when the page is unloaded*/

});

 

You can change the part highlighted in blue font to whatever dates you would like to be your start and end dates on the calendar


Leave a Reply