[Solved] How do I conditionally show a text box based on the length of an answer?


I’m building a form for users to report technical problems. There will be an essay/long answer for them to enter details of the problem. To avoid short and unhelpful answers, I’d like to conditionally show a piece of text which says ‘That’s a little short, consider adding a bit more detail to help us resolve the problem’ if the answer to a given question is less than, say, 30 characters long.

I’m guessing regex might be the answer here, but I have no idea about such witchcraft.

Alex Walker asked

    Best answer


    Hi Alex! I like to dabble in witchcraft every now and again, so I thought I’d pop in and show you what such a Regex validation pattern might look like to achieve your desired behavior.

    After adding a Text/Media element with your warning message (“That’s a little short, …”), edit this element and go to it’s Logic tab, and add a logic condition based upon your Essay/Long answer question. The operator would be “matches regex pattern”, and in the final field, paste the following:


    This will cause your warning message to show if a respondent enters some text less than 30 characters in length. The ’30’ in the regex pattern may be changed to any other number to change the behavior (50, 123, 500, …), but if you edit the regex pattern, be sure not to change or remove any other characters.

    I hope you find this helpful, and may it encourage you or others to one day venture down the rabbit hole

    Nathan - Survey Astronaut answered

      I think you’re in luck – and no sorcery/witchcraft required in this case.

      If you add an Essay question to your survey, you can actually set a minimum character or word count under the Validation tab.

      If someone tries to move on to the Next Page, they trigger an error message such as:

      “You have typed fewer words than required (1 of 5 words)” (you can customize this error message under Text and Translations)

      I suppose the main drawback here would be that is does force that minimum (would not be optional)… which could get a tad cumbersome for the survey takers…

      Hopefully this is a good starting point

      Dominic Sharpe answered

        Brilliant, thank you!

        Alex Walker answered

          Hi Dominic,

          That certainly gives me a solution to work with. I’d like to find my perfect answer though if anyone has any idea on that, if for no other reason than I’m now curious as to how to do it!

          Constantly happily surprised by what I can get SG to do!


          Alex Walker answered


            Question stats

            • Active
            • Views13935 times
            • Answers4 answers
            • Followers0 followers