We have been using the JS below directly within a form-type question to 1) add the "$" before each of the input fields and 2) validate so that only numerical values are entered and they are converted to display commas to the respondent when it is 1,00+ (our respondents have values in the millions +).
We have this all working properly; however, I would like to run calculations with these values after a page break within a text/graphic question type. In order to do so for any values for 1,000+ , I'd have to convert from a string to a numerical value to allow the Qualtrics calculation to work.
Is the conversion something that I could add to the Unload portion of the JS on the same question just below this script? Forgive me, I'm still quite the beginner with JS and I also couldn't find a similar existing question in my search.
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place Your JavaScript Here*/
// This code adds # prefix before textbox
var questionId = this.questionId;
var prefix = "$ ";
crAddInputPrefix(questionId, prefix);
// This code filters text other than numbers entered from keyboard and
// formats numbers with commas between each group of 3 digits for readability.
var InputId1 = $("QR~"+this.questionId+"~1");
var InputId2 = $("QR~"+this.questionId+"~2");
var promptText = "";
crAddInputTextNumberValidator(InputId1,promptText);
crAddInputTextNumberValidator(InputId2,promptText);
});
Page 1 / 1
I have the same question!
I have the same question!
Use the addOnPageSubmit() function.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.