I have a client who has some JS in a historical project that is breaking. When the survey participants goes to the next page and then back the last two formats do not show. Below is the explanation from the client. Here is a video depicting what is going on and the code https://www.screencast.com/t/ZYm9E0qT.
jQuery('input[type="text"]').eq(0).after(" (e.g., 2,000)");
jQuery('input[type="text"]').eq(1).before("USD");
jQuery('input[type="text"]').eq(1).after(" (e.g., 4,500,000)");
jQuery('input[type="text"]').eq(2).before("USD");
jQuery('input[type="text"]').eq(2).after(" (e.g., 6,000,000)");
jQuery('input[type="text"]').eq(3).after(" % (e.g., 90)");
jQuery('input[type="text"]').eq(4).after(" (e.g., 50)");
jQuery('input[type="text"]').eq(5).after(" (e.g., 5)");
There is custom validation and Java in Q2 of the 2021 SOO. The purpose of the Java is so that the fields highlighted below appear in the survey.
This is what it should look like (and it does until you hit the “Back” button in the survey)
But if you enter data that doesn’t meet the validations and get an error, correct it, Save and Continue and then try to go “Back”, the Java goes out of order and it looks like it deletes the first two Java codes. In fact, in further testing, you don’t have to get an error message for the Java to go out of whack … it seems like it is triggered by using the “Back” button in the survey.
Here's to hoping someone can help!
Alicia
JavScript Breaking When Hitting the Back Button
Best answer by Husain_Burhanpurwala
Paste this code and it should work for you:
Qualtrics.SurveyEngine.addOnReady(function()
{
jQuery('input[type="text"]').eq(0).after(" (e.g., 2,000)");
jQuery('input[type="text"]').eq(1).before("USD");
jQuery('input[type="text"]').eq(1).after(" (e.g., 4,500,000)");
jQuery('input[type="text"]').eq(2).before("USD");
jQuery('input[type="text"]').eq(2).after(" (e.g., 6,000,000)");
jQuery('input[type="text"]').eq(3).after(" % (e.g., 90)");
jQuery('input[type="text"]').eq(4).after(" (e.g., 50)");
jQuery('input[type="text"]').eq(5).after(" (e.g., 5)");
});
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.

