I am looking for a script that is similar to what is shown below for word count, but for character count instead. My JavaScript abilities are extremely limited and I have been unable to successfully adapt this script for character count.
The goal is to be able to display the characters within a text entry box to the survey respondent.
I am also interested in knowing if there is a way to modify the character count so that it includes (or excludes) spaces.
Thank you for any advice/assistance.
Here is the word count script I have previously used:
Qualtrics.SurveyEngine.addOnload(function() {
var q = jQuery("#"+this.questionId);
var input = q.find(".InputText");
input.after("
var display = q.find(".wordCount");
countWords(input.get(0));
input.on("input", function() { countWords(this) });
input.blur(function() { this.value = this.value.trim(); });
function countWords(el) {
if(el.value.length > 0) display.text(el.value.match(/\\S+/g).length);
else display.text("0");
}
});
The above code is from this link.