Validate Scanned Barcodes and Keyboard Entries

Improve Data Collection Accuracy

You can improve data collection accuracy by automatically capturing just the right data based on pre-defined patterns.

A. Validate Camera Scans

First, app-user prompts (aka “Questions”) can use the built-in camera of your iOS and Android OS devices to scan secondary barcodes. Among many other barcode scanner configurations, you can use the Smart Scan option with regular expressions (“regex”) to define patterns that will only capture barcodes if they meet the pattern’s criteria.

For example, let’s say the the pattern specifies that you can scan 5-digit barcodes. Then, the camera will only capture 5-digit barcodes. Also, it will ignore other barcodes. The pattern can be as simple or as complex as you need it to be. Moreover, you can create multiple sets of acceptable patterns.

Importantly, the Smart Scan configuration, using regex will minimize the collection of bad data.

Also, you can find the examples of regex patterns at the end of the Pattern Validation article. This discusses how to use regex for primary scans made from the Tap to Scan screen. Also, the same regex examples apply to secondary scans and would simply be entered in the “Match barcode value pattern” field (see below).

An Image that shows where to enter the regular expression

B. Validate Manual Entries and Keyboard Wedge Barcode Scans

Also, you can validate answers to prompts that your app users manually entered or scanned from a keyboard wedge, such as a built-in imager or scanning accessory. To accomplish this, you need to use a Custom Question with an HTML script that works online or offline.

Here, coding is not necessary. However, you can write your own script if you’re a developer. Also, for the no-code option, you simply replace the regex pattern in the extended version of our zip code HTML script. There are two HTML versions: Numeric Entry and Alphanumeric Entry.

Simply, all you need to do is change the regex pattern in the HTML script. You can find the Regex pattern examples at the end of the Pattern Validation article. They apply here as well. If you need help, let us know what you’re trying to accomplish and we can advise you accordingly.

Once you know the regex pattern you want to use, find this in the HTML script:

// Regular expression for validating zip code format.
var postalCodeRegExp = new RegExp(“^\\d{5}(-\\d{4})?$“);

Then, in a text editor like Notepad, replace the zip code regex ^\\d{5}(-\\d{4})?$ with your own regex pattern. For example, if you want to allow only 5 digits to be valid as a keyed entry or scanned entry, you would replace ^\\d{5}(-\\d{4})?$ with the regex pattern ^([0-9]{5})$. The result in the HTML script would then be:

// Regular expression for validating zip code format.
var postalCodeRegExp = new RegExp(“^([0-9]{5})$“);

Copy and paste the HTML script into the Custom Question’s HTML form field.

An Image that shows the Custom Question Form Field

in Data Collection