JavaScript To format the number to three digit separater for output | XM Community
Skip to main content

As I could not find the same question, I would like to ask below as a new question.
I would like to add Javascript in question.
To restrict the user to input the number
To output the inputted number to three digit separater
For example: If user input "1000" automatically change to "1,000"

Hi there, I found a thread that I think will be helpful to you:
https://community.qualtrics.com/XMcommunity/discussion/7469/adding-commas-to-numeric-responses-in-a-matrix-table
In that, C_Bohn provides some JavaScript that adds the comma delimiter. Add the below to your survey's Header over in the Look & Feel:

Then, add the below to the Text Entry question's JavaScript:
var inputs = jQuery("input[type='text']");
inputs .toArray() .forEach(function(field)
{
new Cleave(field,
{
numeral: true,
numeralThousandsGroupStyle: 'thousand'
});
});


Tom_1842 Hi I am so grad you added a comment. It helped a lot to understand the logic and build the question. thank you very much for your kind answer.



https://community.qualtrics.com/XMcommunity/discussion/comment/46529#Comment_46529How would I add a prefix into this code? I would like to add '$' into the text entry box.


Leave a Reply