How do I prepare a multiline textarea to pass through Qualtrics Response API? | XM Community
Skip to main content
Solved

How do I prepare a multiline textarea to pass through Qualtrics Response API?

  • November 16, 2021
  • 1 reply
  • 29 views

pogi
Level 2 ●●
Forum|alt.badge.img+14

I have tried all sorts of regex javascript etc. It seems to break with line breaks\\newlines ("\\n") and quotes (single and double).

Best answer by pogi

I was able to put some regex and replace functions together to make it work.

Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
var input = jQuery("#"+this.questionId+" .InputText");
input.val(input.val().replaceAll('"',""));
input.val(input.val().replace(/(\\r\\n|\\n|\\r)/gm, " "));
});

1 reply

pogi
Level 2 ●●
Forum|alt.badge.img+14
  • Author
  • Level 2 ●●
  • Answer
  • November 16, 2021

I was able to put some regex and replace functions together to make it work.

Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
var input = jQuery("#"+this.questionId+" .InputText");
input.val(input.val().replaceAll('"',""));
input.val(input.val().replace(/(\\r\\n|\\n|\\r)/gm, " "));
});