Validation: make sure the answers you get are usable | LimeSurvey

Validation: make sure the answers you get are usable

About validation

Validation checks answers before participants can move on. It ranges from requiring an answer to rules you write yourself as an equation. Everything is set per question in Question settings.

Require an answer

Select the question and set Mandatory in Question settings:

  • On: participants must answer before they can go to the next page.
  • Soft: participants who skip the question are reminded once, then they can go on without an answer.
  • Off: the answer is optional. This is the default.

Use the limits of the question type

Most question types have limits of their own. Open Advanced in Question settings and click Expand all to see them:

  • Max characters (General): text and number questions.
  • Minimum value, Maximum value and Integer only (Input): number questions.
  • Minimum answers and Maximum answers (Logic): multiple choice questions.
  • Input validation (General): text and number questions. A regular expression the answer must match, for example /^[0-9]{5}$/ for a five-digit postal code.

Write your own rule

  1. Select the question and click Advanced in Question settings.

  2. Open Logic (1).

  3. Type the rule into Question validation equation (2). The answer is accepted when the equation is true. The example strlen(Q002) >= 20 accepts answers of at least 20 characters.

  4. Type the message for participants into Question validation tip (3), for example "Please write at least 20 characters."

The Logic section of the Question settings with three areas numbered 1 to 3, Logic, the validation equation and the validation tip

The equation names the question by its code, here Q002. See Question and answer codes. Question types with subquestions also have Subquestion validation equation and Subquestion validation tip, which check each subquestion on its own.

Tip: Validation works in the running survey, not in the editor. Test it with the eye icon in the top bar: give a wrong answer and check that your tip appears.

Next steps

FAQ

What is the difference between On and Soft?

On blocks the next page until the question is answered. Soft shows a reminder once and then lets participants go on, which keeps them in the survey while still nudging for an answer.

Where did the validation settings of the classic editor go?

They are in Question settings, view Advanced: Question validation equation and Question validation tip under Logic, Input validation under General.