Currency next to text box | Experience Community
Skip to main content
Solved

Currency next to text box

  • March 26, 2026
  • 2 replies
  • 16 views

Forum|alt.badge.img+1

Hi, I have a Text Entry question for which I am asking a price. I have two issues: 

  1. I would like to have the currency (.kr) next to text box. I know that I have to use a Javascript as I used it already in a previous study, but it does not work anymore. I tried several scripts, but nothing seems to work. This is the last script I tried, suggested my ChatGPT. 

    Qualtrics.SurveyEngine.addOnReady(function () {
      const qid = this.questionId;

      function addPrefix() {
        const q = document.querySelector("#question-" + qid);
        if (!q) return;

        const input = q.querySelector('input[type="text"], .text-input');
        if (!input || q.querySelector(".kr-prefix")) return;

        const prefix = document.createElement("span");
        prefix.className = "kr-prefix";
        prefix.textContent = "kr. ";
        prefix.style.marginRight = "6px";

        const wrapper = document.createElement("span");
        wrapper.style.display = "inline-flex";
        wrapper.style.alignItems = "center";

        input.parentNode.insertBefore(wrapper, input);
        wrapper.appendChild(prefix);
        wrapper.appendChild(input);
      }

      addPrefix();
      setTimeout(addPrefix, 300);
      setTimeout(addPrefix, 1000);
    });

  2. How can I set the validation to be only numbers? You could do it from the Add validation button, but that option now includes only lenghth options and similar, the “numeric only” option is gone and I am not sure how to set that now.

I hope someone can help!

Thanks

Giulia

Best answer by Anushree R

Hi, for validation, please ensure that the Text type is set to “Single line.” This will enable the option to set the Content type to Numbers under Validation.

For adding currency next to text box, check out this community page. 

2 replies

Forum|alt.badge.img+4
  • Level 2 ●●
  • Answer
  • March 26, 2026

Hi, for validation, please ensure that the Text type is set to “Single line.” This will enable the option to set the Content type to Numbers under Validation.

For adding currency next to text box, check out this community page. 


  • Level 4 ●●●●
  • March 26, 2026

Hi,

As Anushree mentioned above, you can set the validation. But to display a text before or after a box text, you dont need that much of coding. Just use the code below and change accordingly.

jQuery("#"+this.questionId+" .InputText").after(" ############# ") -- this is to display a text after the text box. if you need it before, change “after” to “before:”