Validating number questions
You can validate numerical input from respondents using a Validation Message question type. This is helpful when you want to enforce a sum total for numerical values such as enforcing that percentage values add up to 100.
For more information, see Validation Message Question.
- First, add a question where users will input numbers such as a Matrix Number Boxes question (Matrix Number Boxes Question):
To validate that the numbers entered in Input 1 and Input 2 add up to 100, you will need to add a Validation message after this Matrix Number Boxes question.
- After building your Matrix question, right-click the last row (Input 2 question) on the Edit tab, and click Insert After.
- Click Validation Message from the Question Gallery.
- In the Validation Message editor, enter the message that will appear if the sum total of question 1 is not 100 - such as The sum total in the last question does not add up to 100. Please go back and correct your answer.
- Click Ask if. The Ask if page displays.
- On the Ask if page, choose Other from the drop-down menu, and click OK. The Ask if Conditional page displays.
On the Ask if Conditional page you will enter a formula to validate that the numbers entered in Input 1 and Input 2 of question 1 add up to 100. The formula will state that if Input 1 and Input 2 do not equal 100 a validation message should display.
The formula will need to reference Input 1 and Input 2 from question 1. You can reference question fields using Vista syntax as described in Using Piping and Advanced Ask if Logic. In our example, you will reference Input 1 with [Q1a] and Input 2 with [Q1b] and enforce the "do not equal" rule with the operator !=. The formula to validate question 1 is: [Q1a]+[Q1b]!=100.
- Enter the formula [Q1a]+[Q1b]!=100 in the Ask if Conditional page text area, and click OK.
- On the Validation Message page, the formula is displayed next to the Ask if button.
- Click OK to return to the Edit tab.
- To test the formula, click Test Logic from the left-hand menu.
- In question 1, enter numbers that do not add up to 100:
- Click Next.
The validation message displays and the user must click the Back button to return to question 1.
How do I make questions conditional?