Capitalize all letters in the text-box | XM Community
Skip to main content
Solved

Capitalize all letters in the text-box

  • April 4, 2020
  • 12 replies
  • 615 views

Forum|alt.badge.img

I am trying to capitalize all the letters in the text box as the respondent types. Is there a way of doing that? Thank you.

Best answer by rondev

Use the below code
jQuery(".InputText").css("text-transform","uppercase");

12 replies

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • Answer
  • April 5, 2020

Use the below code
jQuery(".InputText").css("text-transform","uppercase");


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • April 5, 2020

That will make the input appear in uppercase but it won't store it as uppercase. To do that, you need:
jQuery("#"+this.questionId+" .InputText").on("input", function() { this.value = this.value.toUpperCase(); });


Forum|alt.badge.img
  • Author
  • April 5, 2020

Thanks a lot! This works. I really appreciate your response. I am going to be piping the text, and want the piped text to be in uppercase too. This saves me having to code further.


KWigg
Level 2 ●●
Forum|alt.badge.img+9
  • Level 2 ●●
  • April 16, 2020

TomG me again! How would this code differ if applying to a matrix table?


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • April 17, 2020

How would this code differ if applying to a matrix table?

Change the last part of the selector to " td input[type=text]"


KWigg
Level 2 ●●
Forum|alt.badge.img+9
  • Level 2 ●●
  • April 27, 2020

Thank you, TomG !!


  • March 22, 2021

Hi TomG that line doesn't seem to be working for me and I'm wondering if the existing code has something to do with it. Where would I put it within the following?
Qualtrics.SurveyEngine.addOnload(function()  {
//hide next button
this.hideNextButton();
//press enter to go to next question
    document.on("keydown", function(e) {
         if (e.keyCode === 13) $('NextButton').click();
    });
});


Qualtrics.SurveyEngine.addOnReady(function(){
//cursor in text box
$(this.questionId).down('.InputText').focus().defer();
});
Edit: never mind I figured it out - it needed to go before the cursor line in the OnReady function


Forum|alt.badge.img+3
  • Level 2 ●●
  • November 25, 2021

TomG what about converting to capital first letter, lower case for the rest? Thanks


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • November 26, 2021

https://community.qualtrics.com/XMcommunity/discussion/comment/42098#Comment_42098There isn't an equivalent toUpperCase() JS function for proper (aka title) case. You could create your own function utilizing regex.


VirginiaUKY
Level 2 ●●
Forum|alt.badge.img+10
  • Level 2 ●●
  • March 31, 2022

TomG Your code works beautifully for text entry and form field questions. However, I have a situation where I only need one field of a multi-field Form Fields question type to be capitalized. I've been trying to figure out how to modify your code to apply to only to that one specific field, but haven't been successful. Would you mind providing an example of how that would be done? In my case, the field I'm trying to reference is ${q://QID5/ChoiceTextEntryValue/3} and I'm applying the js to the question itself.
I've been able to solve the problem by using an embedded data placeholder and the below js applied to a later question, but your approach is much more elegant and I would like to learn how to apply it to this particular situation. Thank you in advance!
var other_ID = "${q://QID5/ChoiceTextEntryValue/3}".toUpperCase();
Qualtrics.SurveyEngine.setEmbeddedData("other_ID", other_ID);


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • March 31, 2022

https://community.qualtrics.com/XMcommunity/discussion/comment/45075#Comment_45075jQuery("#"+this.questionId+" .InputText").eq(2).on("input", function() { this.value = this.value.toUpperCase(); });
The above will only apply to the third text input in the question (indices start at 0).


VirginiaUKY
Level 2 ●●
Forum|alt.badge.img+10
  • Level 2 ●●
  • March 31, 2022

https://community.qualtrics.com/XMcommunity/discussion/comment/45076#Comment_45076TomG Thank you SO much for the fast reply and the reminder about indices! That worked perfectly. I see you all over these boards and always learn a lot from your answers. 🙏