Text Entry Box disappears when next is selected | Experience Community
Skip to main content
Question

Text Entry Box disappears when next is selected

  • February 4, 2026
  • 3 replies
  • 26 views

Forum|alt.badge.img+1

I’m using the following JavaScript to have a dynamic Text Entry box when “other” is selected. If the user selects, “other” but doesn’t type anything in the text entry box, the box disappears when the user hits the “next” button. The text entry is required when other is selected, and I don’t want users to be confused by the disappearing text entry box if they accidentally hit ‘next’ before typing in their response. 
 

Qualtrics.SurveyEngine.addOnReady(function () {
    // Hide the text box initially
    var text_box = this.getChoiceContainer().querySelector(".TextEntryBox");
    if (text_box) {
        text_box.hide();
    }

    // Identify the "Other" choice (usually the last one, e.g., index - 1)
    var n_choices = this.getChoices().length;
    var other_choice_id = n_choices; 
    
    // Listen for clicks on the choices
    this.questionclick = function (event, element) {
        if (element.type == "radio" || element.type == "checkbox") {
            // Check if the clicked element is the 'other' option
            if (element.id.split("~")[2] == other_choice_id) {
                if (element.checked) {
                    text_box.show();
                } else {
                    text_box.hide();
                    text_box.value = ""; // Clear text on deselection
                }
            } else {
                // If a different option is selected, hide and clear 'other'
                text_box.hide();
                text_box.value = "";
            }
        }
    };
});

3 replies

Forum|alt.badge.img+1
  • Level 1 ●
  • February 6, 2026

Hi ​@mross , Disable the text entry in ‘other’ option of MCQ question and remove the script.

Instead add a text entry question next to the MCQ and add an in-page display logic and enable force response. So that this question will be displayed only if ‘other’ option is selected, it will be mandatory and it will not disappear when the respondent clicks next.

Then add the below script in text entry question to hide the question text. So that 2 questions together will look like single question.

jQuery("#"+this.questionId+" .QuestionText").hide().css({"padding":"0px"})

 


Forum|alt.badge.img+1
  • Author
  • February 6, 2026

That’s so great, Anushree. I had looked at this option and couldn’t make it work before but the Java on the 2nd part is what got me over the finish line.
Is there a way to “hide” the text entry question? I currently have it colored white, so it is hidden. If the user doesn’t enter anything and hits next the white text appears because that text entry is required. 
How can i build on the script you provided so the text entry question does not show, only the text entry box. 
Thank you!


Forum|alt.badge.img+24

Hi ​@mross , Disable the text entry in ‘other’ option of MCQ question and remove the script.

Instead add a text entry question next to the MCQ and add an in-page display logic and enable force response. So that this question will be displayed only if ‘other’ option is selected, it will be mandatory and it will not disappear when the respondent clicks next.

Then add the below script in text entry question to hide the question text. So that 2 questions together will look like single question.

jQuery("#"+this.questionId+" .QuestionText").hide().css({"padding":"0px"})

 

Hi ​@mross,

Anushree’s suggestion on display logic have already “hide” the question at the start.

You might want to look at the Display Logic documentation.