Adding background text to Text Entry question | XM Community
Question

Adding background text to Text Entry question

  • 19 April 2024
  • 6 replies
  • 39 views

Userlevel 2
Badge +9

Hello

 

I’d like to replicate adding the greyed out text into the nan-mandatory text entry questions? Can anyone help?

 

 


6 replies

Userlevel 7
Badge +27

Add a placeholder attribute to the text entry element:

Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" .InputText").attr("placeholder","background text goes here");
});

Note: jQuery selector would be different for Simple layout.

Userlevel 2
Badge +9

hi @TomG , thanks for the solution. I am not very technical minded, would you mind helping me a bit further?

AM I adding the above script into the JavaScript section? basically replace the circled part with your script? and which elements of the script I need to personalise? replace questionId with QID23_TEXT ? and anything else?

 

Userlevel 7
Badge +27

@AnnaP,

Yes, you’ll update the JavaScript section. Just replace everything that is there with the code I provided. The only customization needed is replacing "background text goes here" with the placeholder text you want in your text input field.

Userlevel 2
Badge +9

hi @TomG 

it’s not working. I tried this:

Qualtrics.SurveyEngine.addOnload(function()
{
    jQuery("#"+this.questionId+".InputText").attr("placeholder","background text goes here");

});

Qualtrics.SurveyEngine.addOnReady(function()
{
    /*Place your JavaScript here to run when the page is fully displayed*/

});

Qualtrics.SurveyEngine.addOnUnload(function()
{
    /*Place your JavaScript here to run when the page is unloaded*/

});

 

and tried this:

Qualtrics.SurveyEngine.addOnload(function()
{
    jQuery("#"+this.questionId+".InputText").attr("placeholder","background text goes here");

});

 

I do not see any background text

Userlevel 7
Badge +27

@AnnaP - You are missing a space before .InputText.

Userlevel 2
Badge +9

Hi @TomG, I’ve got it. It’s now showing in the preview. Should it be showing in the survey builder as well?

Also another question. What would I have to do to change font colour. I am thinking lighter grey.

 

Leave a Reply