How do I validate a text response question by word count, not character count? | XM Community
Skip to main content

Hello!
I am trying to validate a text entry question such that people cannot move on without typing at least 50 words. I would also like to display to participants, as they type, their word count over the minimum. So, for example, someone would see that they are at 35/50 words.
I have read several other threads on this topic but they are all a bit out of date and include instructions (e.g., buttons) that I simply do not have on my Qualtrics, possibly because of all the cosmetic updates since these older posts.
To accomplish the word minimum, many responses suggest changing the "Matches Regex" option to include some script that specifies a minimum word value. But when I select a text entry question and turn on Validations, I personally have no option on my Qualtrics for "Matches Regex", only options for "Minimum Length', "Maximum Length", "Character range" and "Custom". Moreover, when I click custom, it only gives me the options to validate responses conditional upon answers to previous questions in the survey. I cannot insert any sort of regex.

To accomplish the live word display, I have tried pasting in other's custom Javascript code from other threads but I am unable to save as Qualtrics tells me there are errors with the code and I am not familiar with Javascript, only R, so I can't really debug. Perhaps there are variable names in the Javascvript I am supposed to be changing, but I don't know Javascript well enough.

Could someone help? Much appreciated!

Cultevolab You can enter regex in Custom validation. You got close to that location when you said it allows only answers from previous questions. You can select the current question (which is the default shown when you open Custom validation), then choose the text entry and you will get the Regex entry option. If you have a proven regex for this validation, you should be able to enter it there.


https://community.qualtrics.com/XMcommunity/discussion/comment/39320#Comment_39320Thank you TSAcc ! That's really helpful and I can now validate the question based on minimum words rather than characters using some other regex I found on the Qualtrics forum.

Would you also happen to know how to display the word count to participants as they type? I've seen several posts on this, but when I past their code in it simply doesn't work.


Cultevolab I recommend TomG's code at https://gist.github.com/marketinview/aaf237fea91d2f7947fa4f170ac16486. It is compact and elegant.


https://community.qualtrics.com/XMcommunity/discussion/comment/39358#Comment_39358Thank you for the lead!!


Leave a Reply