Javascript for side by side question with date formatting | XM Community
Skip to main content
Solved

Javascript for side by side question with date formatting


Forum|alt.badge.img+1

Hello,

I have a question about inserting Javascript in order to give the statements in a side-by-side question a date format.  There is one column with two possible answers and three statements.  I want each box to have a mm/dd/yyyy formatting.  I inserted javascript to do so, and it works, but only in the first box.  I’m not sure how to make it apply to each of the possible boxes.

Thank you for any help.  I am not familiar with Javascript at all 😕

 

Best answer by ChiragK

Try this code and it should work!

 

Qualtrics.SurveyEngine.addOnload(function(){
    /* Place your JavaScript here to run when the page loads */
});

Qualtrics.SurveyEngine.addOnReady(function(){
    jQuery("#" + this.questionId + " .InputText").each(function() {
        new Cleave(jQuery(this), {
            date: true,
            delimiter: '/',
            datePattern: ['m', 'd', 'Y']
        });
    });
});

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

 

View original

2 replies

Forum|alt.badge.img+8
  • Level 2 ●●
  • 77 replies
  • Answer
  • August 14, 2024

Try this code and it should work!

 

Qualtrics.SurveyEngine.addOnload(function(){
    /* Place your JavaScript here to run when the page loads */
});

Qualtrics.SurveyEngine.addOnReady(function(){
    jQuery("#" + this.questionId + " .InputText").each(function() {
        new Cleave(jQuery(this), {
            date: true,
            delimiter: '/',
            datePattern: ['m', 'd', 'Y']
        });
    });
});

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

 


Forum|alt.badge.img+1
  • Author
  • 3 replies
  • August 14, 2024

That works perfectly, thank you!!


Leave a Reply