How to count the characters on a text entry question and record the numeric value as embedded data | XM Community
Skip to main content

Hi all,
I have a text entry question and want to count the number of characters the response has and record this numeric value as an embedded data. This should not be visible for the respondents. I want to use the embedded data later on to trigger actions. Does anybody knows how to do it and what the java logic would be?
Thanks

Qualtrics.SurveyEngine.addOnReady(function () {
    let text_entered = this.questionContainer.querySelector(".InputText");
    text_entered.oninput = function () {
        Qualtrics.SurveyEngine.setEmbeddedData("text_length", text_entered.value.length);
    };
});


Thanks Ahmed!
So, i should paste this code in the text entry question and text_lenght would be the embedded data, right?


In the javascript of a text entry question.


Thanks ahmedA,
It works perfect! you are a guru!


Leave a Reply