Validating registration numbers with input masks

In many cases, you may need to collect codes from external systems. Examples of such codes include:

  • Phone numbers
  • Refugee registration numbers
  • National ID Numbers
  • Driving license numbers

In many cases, you won’t have a complete list of valid regration numbers, so the best you can do is to ensure that the provided number has the correct format. This will help reduce data entry error.

For codes that always have the length and combination of letters and numbers, you can use input masks to validate the input. For more complex codes, you can use a validation rule with regular expressions instead.

Even if an external code is composed of all digits, always use a Text field, not a Quantity field. Quantity field should only be used for measured quantities.

Compose the input mask

Review the format of the code that you need to validate. Are their parts of the code that are always the same? Input masks use a simple syntax to describe a pattern:

Character Meaning
0 User must enter one digit (0 to 9)
L User must enter a letter (A-Z)
A User must enter a letter (A-Z) or a digit (0-9)
\0 User must enter the digit 0
\L User must enter the letter L
\A User must enter the letter A

Any other character is assumed to be fixed.

Example Input mask Explanation
Family registration number 1-00000000 All registration numbers start with “1-” followed by exactly 8 digits
Case worker initials LLL Exactly three letters
Case worker ID 000 Exactly three digits
Administrative number 2\02\0-00-000 Starts with “2020-” followed by a dash, followed by two digits, a dash, and three digits.
US Phone Number (000) 000-0000 Area code followed by 3 digits, a dash, and then exactly 4 digits.

Add the field

Open the form designer for the form to which you want to add the form.

  • Click “Add a field”
  • Select “Text” from the list of field type
  • Enter “Registration Nubmer” as the field’s label
  • Enter “1-00000000” as the input mask
  • Save the form
Next item
Validating phone numbers with regular expressions