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

Capitalize all letters in the text-box

  • Apr 4, 2020 11:16 PM UTC
  • 12 replies
  • 715 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");

View original

12 replies

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • Answer
  • Apr 5, 2020 11:44 AM UTC

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


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Apr 5, 2020 1:09 PM UTC

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
  • Apr 5, 2020 1:12 PM UTC

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 ●●
  • Apr 16, 2020 9:39 PM UTC

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


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Apr 17, 2020 1:31 PM UTC

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 ●●
  • Apr 27, 2020 8:24 PM UTC

Thank you, TomG !!


  • Mar 22, 2021 11:59 PM UTC

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 ●●
  • Nov 25, 2021 2:30 AM UTC

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


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Nov 26, 2021 3:51 PM UTC

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 ●●
  • Mar 31, 2022 7:50 PM UTC

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 ●●●●●●●●
  • Mar 31, 2022 8:02 PM UTC

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 ●●
  • Mar 31, 2022 8:22 PM UTC

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. 🙏