Entry Validation

☑️ What entry validation ?

Beside checking if a value has been entered in a field you may also setup more advanced rules using regular expression to make sure that the text entered by the respondent matches certain conditions.

You may also set the maximum length of characters allowed to be entered in your field.

circle-info

Advanced users may also create a custom field based answer type using custom javascript validation to validate the respondent entries.

🔢 Regular expressions

A regular expressionarrow-up-right (regex) is a string based search pattern that will check that the text entered by the respondent matches the expression pattern or not.

Using these patterns you check a value using patterns like emails, numbers, zip codes etc ... Almost any field based type can be validated against a regular expression created using the regular expression editor.

➕ Adding a regular expressions

To add a regular expression go to the answer properties page and click on the + icon

circle-info

Regular expressions are only available to the user who created them. If you would like to share your regular expression with all the other ngSurvey users you may turn on its built-in property.

🔅 Regular expression properties

  • Name is the display name of the regular expression.

  • Regular expression is the actual regular expression pattern that will be used to match the respondent answer .

  • Error message error message that will be shown to the respondent if its entry doesn't match the pattern.

  • Built in let us share the regular expression with all the other users.

circle-info

You may find pre-made regular expression and test yours at https://regex101.com/arrow-up-right

🔢 Javascript

For field based answers you can set the Javascript validation and Validation message property on the answer properties to use custom javascript code to validate your answer. In the code below respondentAnswerValue will be replaced by the actual value of the field. If the code returns false ngSurvey will block the submit or navigation and show the validation message.

In the code below we are using the getAnswer in the validation context to get a value from another answer in the survey. Here we are looking up an answer with a reporting alias set to "hh_people".

The validation context support following method and properties

Last updated

Was this helpful?