Remove label in multiple choice question and only allow number entry | XM Community
Skip to main content
Solved

Remove label in multiple choice question and only allow number entry

  • February 19, 2021
  • 5 replies
  • 400 views

Forum|alt.badge.img+1

Hello,
I have a multiple-choice question with 3 answer options. The first one is supposed to be just a text entry box but a) only numbers should be allowed to enter, and b) there should not be anything else but the textbox (so, no label of the answer option). Basically, I want a text entry box with numbers only allowed, and then 2 options with "don't know" and "refuse to answer".
Hope this makes sense and someone can help me.
Thanks a lot!

Best answer by ahmedA

Oh that! Let the text be anything. Add this to your JS:

this.getQuestionContainer().querySelector(".TextEntryBox").previousElementSibling.hide();

5 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • February 19, 2021

Make the text of option a to:

...

You can use validation to allow only numbers.


Forum|alt.badge.img+1
  • Author
  • February 19, 2021

https://www.qualtrics.com/community/discussion/comment/34751#Comment_34751Thanks for your answer but is there another way than just making the text transparent? It looks odd when taking the survey.
On the validation issue, it doesn't let me allow only numbers. In the custom validation option, it only lets me add an error message.


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • February 19, 2021

Change style to

"display:none"

Add this line to your JS:
this.getQuestionContainer().querySelector(".TextEntryBox").type = "Number";


Forum|alt.badge.img+1
  • Author
  • February 19, 2021

Like this? ...
It still leaves this grey box above the text entry
Screen Shot 2021-02-19 at 15.18.00.png
Thanks, the JS code for the number validation worked!


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • Answer
  • February 19, 2021

Oh that! Let the text be anything. Add this to your JS:

this.getQuestionContainer().querySelector(".TextEntryBox").previousElementSibling.hide();