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);
});
JavaScript to Convert String to Numerical Value After Custom Validation When Entering Monetary Value
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
