Set characters limit in text questions

Hello. Is there a way of limiting the maximum number of characters for a text question response?

1 Like

Why would you want to do that?

You can always truncate your data after it gets exported:

Best, Sergiy

Hello Sergiy, thank you so much for your reply.
What I actuallly need is to limit the response field so that interviewers can’t enter more than 30 characters in their answers.
Best, Ana.

I understand what a limit is, why is it needed?

I completely understand why limiting the number of characters in a text response could be beneficial. It can be necessary to streamline data entry in the field or to keep responses concise and relevant.

One way to achieve this is by using a regular expression (regex) in the response field’s configuration. For example, you could use the following regex to limit responses to a maximum of 30 characters:


I think this regular expression will ensure that any input response has between 1 and 30 characters, including spaces, you can test it in webs like

but I dunno if its ok for ssolution regex rules

Best regards,

It’s for a question “Other (specify)”.As an answer, interviewers should provide type of organisaitons such as research council, private company, community-based organisation, etc. So we don’t want to allow the possibility to answer with long texts . We’ve tried some regex but didn’t work as expected.

Thank you so much Vladi. I’ve tried your expression (as others) but the field completes as it’s shown in the screenshot

  1. indicate exactly this in the instructions for the question. Ask not “Other”, but “Please specify the other type of organization, be brief”.
  2. Add a validation rule: self.Length<=30 with a message “Value is too long, please be brief”.
  3. Neither nr.1 nor nr.2 will be guaranteeing the content the respondents enter will be short. So you may still want to truncate the content in the end if you are feeding it into some other system, but I’d operate on the full content without truncation.
  4. If the truncated content is needed right in the questionnaire, you can introduce a calculated variable with a varname.Left(30) expression to get the first 30 characters of the answer to varname.
  5. …we don’t want to allow…” is not really an explanation. “The passport number contains 8 digits, so we only want to allow 8-digit content” is a valid reason in my view, for limiting the input, because it allows to immediately catch the invalid passport numbers on entry (and then there are proper tools for solving this in Survey Solutions). As far as I can see, what you are doing is relocating the burden of work from your data processing specialists (who will be reading the ‘other’ items and deciding what to do with them) onto the respondents. Depending on the survey your mileage may vary.
  6. @vladi advised to use regular expressions, but didn’t demonstrate how. Perhaps, sharing an example questionnaire exhibiting this behavior would be helpful. Though given that the check can be done with the simple Length function, I don’t see the point of involving this heavy machinery.

Hope this helps.

Best, Sergiy

1 Like

Hi, I believe the solution provided by @sergiy, using self.Length <= 30, is the most practical approach. Thank you!

Regarding the use of regex, the challenge lies in adhering to a specific set of valid rules dictated by the internal code:


Thanks Sergei, self.Length<=30 was exactly what we needed.

1 Like