Qualtrics – Using Word Count as Validation with Text Entry Questions

There is a very simple way to use the number of words in a text box as Custom Validation. In order to do this, you simply add Custom Validation to “Match Regex” and the regular expression pattern to match is ^\s*(\S+\s+){0,249}\S*$ (change the “0” to the minimum number of words to match and the “249” to the number of maximum words allowed). Here are the steps:

  1. Select your Text Entry question.
  2. Click on Custom Validation in the right panel.
  3. In the 2nd box, select your question text as the text to analyze.
  4. Pull down on the 3rd box and change it from “Equal To” to “Matches Regex”.
  5. In the last text box, paste in the regular expression “^\s*(\S+\s+){0,249}\S*$” (without quotes). Change the upper number to the limit you choose.
  6. You may need to create a new error message in the bottom part. Once you’ve created a custom validation error message, you can select that to pop up when the text response violates the validation. Please see this page for more on Custom Validation and Custom Validation Error Messages: https://www.qualtrics.com/support/survey-platform/survey-module/editing-questions/validation/.
  7. To test your validation, just do a Survey Preview and copy in enough words to trigger the error message (251 or more in my example). To get that much text easily, just go to this Lorem Ipsum generator and you can copy/paste in the words needed. When you submit your survey page, you should get something like before (showing your own custom error message).

Please contact Richard King (kingre@wfu.edu) or Jeff Nichols (nicholjm@wfu.edu) for help on this or more information.

Comments are closed.