Hello. I am using one of the 3 calendar question from the Qualtric library (Demographics-Calendar and Date Questions-Enter a date). I want to make sure that the choosen date is not beyond the current date. How can I do this? Can I use a condition like Display Logic or do I need to write code? Thanks, Al
You would need a code for it.
Put this code in the header:
<link href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css" rel="stylesheet" /><script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
Then, use a Text Entry question for your date question and add the following code to the JavaScript:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
jQuery("#"+this.questionId+" .InputText").flatpickr({
dateFormat: "m/d/Y",
maxDate: "today"
});
});
Sorry. Put the code in the header via Look and Feel - General - Header or the question itself?
And the Java code: add it to the same date question (imported from the Qualtrics library) or create a new Text entry question? Also will it be in the dd/mm/yyyy format?
Could you please clarify.
Thanks.
The header code should go in the Look and Feel->General->Header. When pasting it, make sure you click on the <> button first.
The actual JavaScript code should be added to a new, Text Entry question. This will be used instead of the one you brought in from the Qualtrics library. You can delete that one.
If you want the date in a dd/mm/yyyy format, change the dateformat that I have in the code to the following:
dateFormat: "d/m/Y",
Thanks Josh! Unfortunately its not working. please see the attached screenshots.
Hi. Nothing happens unfortunately. treats it as a normal text question…
OSqiy
Hi Josh,
It’s working now! It doesn’t work in the Simple layout so I had to use the Flat layot. The latter is not ideal but I don’t want to add a substantial code in case it doesnt work. But below is the link for the solution:
Thank you very for your help! Regards, Al
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.