Hi all,
In a side-by-side question, I have participants inputting (a) some text in an essay box, and (b) a numerical rating from a drop-down.
I then use some JavaScript to (a) sort numerical responses into ascending order, and (b) set Qualtrics embedded data based on the text of largest 3 numerical ratings. Everything works fine unless a user inputs a line break or quotation mark in their response, in which case the code breaks & nothing displays.
Anyone know how I can remove line breaks and quotation marks from the user input?
I tried this:
function cleanText(input_string) {
input_string = input_string.replaceAll(/(\\r\\n|\\n|\\r)/gm,"");
input_string = input_string.replaceAll("\\"", "\\'");
return (input_string);
}
var text1 = "${q://QID34%231/ChoiceTextEntryValue/1/1}";
text1 = cleanText(text1)
But this didn't work. My suspicion is that it breaks at the point of initializing the variable
text1if it contains a line break or quotation mark.
I'm rather novice at JS, the sorting function for the matrix was with the help of a friend.
Thank you in advance!