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.
Use the below code
jQuery(".InputText").css("text-transform","uppercase");
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(); });
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.
TomG me again! How would this code differ if applying to a matrix table?
How would this code differ if applying to a matrix table?
Change the last part of the selector to " td input[type=text]"
Thank you, TomG !!
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
TomG what about converting to capital first letter, lower case for the rest? Thanks
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.
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);
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).
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.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.