Number Entry with 'I Don't Know' Option | XM Community
Skip to main content

How can I make a question with a number input box where users can enter a number from 1 to 99, and also provide an option for "I don't know” on the same page/question?

 

 

Hi @hachiware10 :

Create a multiple choice type question. 
Add two options: 

1. Allow participants to enter a number.
2. The “I don’t know” option.
    
To restrict the number input to a range of 1 to 99, you’ll need to add some JavaScript validation.
 
In the “Advanced Question Options,” check the box for “Use JavaScript to add custom validation” and enter the following JavaScript code in the editor:

Validation.addCustomFunction(function(value) {
    if (value === "I don't know") {
        return true;
    }
    return (value >= 1 && value <= 99);
}, "Please enter a number from 1 to 99 or select 'I don't know'");

This JavaScript code checks if the input is a number between 1 and 99 or if it’s “I don’t know.”

 

hope this helps! 


Leave a Reply