Previous Next

Fields in your survey can either be required – in which case they require a non-blank response from the user – or not required. And, for any non-blank response that is entered or selected by the user, you can use a constraint to validate the response; if the user's entry or selection does not meet your constraint, the user will have to correct it before continuing.

In the form designer, you can control the required and constraint settings whenever you add or edit a field. And when adding a constraint, there is a step-by-step wizard that will help you to add common types of field validation.

In the spreadsheet form definition, the required column of your survey worksheet will determine which fields the user can leave blank and which must be filled; enter "yes" into that column to require a response. Then, enter an expression into the constraint column to further validate whatever response is entered or selected by the user.

If the user does enter or select a response, they will only be allowed to proceed to the next question when the expression in your constraint column evaluates to true. If the user tries to move forward with a non-blank response but the expression is false, then a generic "That entry is invalid" message will appear; to override this message on a field-by-field basis, enter another message into the constraint message column. (This is the default manner in which constraints are enforced. However, in the General settings for the SurveyCTO Collect app, you can change the constraint-processing option to "Defer validation until finalized" to skip constraint enforcement until the very end, when users try to finalize their forms for submission. For most forms, though, the default behavior is what you want.)

For example, ". < 130" requires that the entered value be less than 130; ". < 130 and . > 10" also requires it to be greater than 10. You might couple such constraints with a constraint message like "Please enter a valid age." In these constraints, the "." represents the current entry or selection.

You can also compare with a prior field's value, as in ". < 130 and . > 10 and . > ${daughterage}".

The easiest way to build a constraint expression is to use the wizard built into the form designer, or to use the constraint-builder on the server's Design tab: just select Tools, then Build constraint from the Your forms and datasets section.

For details on hand-creating or hand-editing constraint expressions, see the Using expressions in your forms help topic.

To easily test a constraint without having to fill out your actual form, click the Tools icon, then Test constraint from the Your forms and datasets section of the Design tab.

Previous Next