September 10, 2020 • 8 min read
Validating Question Answers Using Regex

Now validate secondary scans, multiple choice answers, and text entries to collect accurate data using the CodeREADr no-code/low-code SaaS platform
We help customers improve the accuracy of their collected data. This is one of many initiatives for achieving that goal. Read more about accurate barcode scanning app.
Periodically, we will share with our users Custom On-Device Validation (COV) scripts that we have created at a client’s request. One of our latest additions is a script for validating question answers using RegEx. Using this script, look for a designated pattern in data, such as a barcode scan, text entry, or text selection. Here is a link to all current COV scripts. Below are the instructions for validating question answers using RegEx.
CATEGORIES
SOCIAL SHARE
Step 1: Create a service
Create a service and collect data with questions as desired. The service must be on-device, not online.

Note the question ID(s) for the questions you will be validating.

Step 2: Advanced Settings
On the advanced settings step, select “Enable on-device custom validation.” In the text box, you will copy and paste this script.

Step 3: Edit the script
Edit the script so that var regex includes only the patterns you would like to use. New additions to the array should follow the following format:
“QUESTION_ID”: [new RegExp(“PATTERN”), “OPTIONAL ERROR MESSAGE”]
For example, if you want to validate that your question answer contains the string “abc”:
“1737556”: [new RegExp(“[sS]*abc[sS]*”), “This ID is not valid.”]

This COV script has a wide variety of uses from secondary ID validation to enabling proper procedures and protocol. Any RegEx pattern can be used to authenticate the given question answer. If you have trouble implementing this script or are unsure if it would work for your use case, contact us via email or LiveChat.