Using Regular Expressions in Forms

Using the Form Element, you can add a Text Field, where you need to set some validation rules to avoid getting wrong or incomplete information. These rules need to be defined by a regular expression (RegEx) that you must enter to validate a specific format in a given string of characters, such as IDs, date, zip code, credit card numbers, etc.

If you are not familiar with regular expressions, or you have no idea how to build one, do not worry, here is a guide that will help you to build a RegEx to validate your custom field.


After building your RegEx, it is very important that you test it before going live. This way, you make sure that the data you want to collect is correct. Here you have a free online RegEx tester: https://www.regextester.com/ 


Ready to use Recipes?

In the following table, you will find the regular expressions for ID validation of certain countries that we have selected. To use them in a Form Element, just copy and paste it into the validation rules field:

Country
ID
RegEx
RegEx Match
  Argentina
DNI
^\d{1,2}\.?\d{3}\.?\d{3}$
00.000.000
0.000.000
00000000
0000000
CUIT/CUIL
^\d{2}\-\d{8}\-\d{1}$
00-00000000-0
  Brasil
RG
^\d{1,2}\.\d{3}\.\d{3}[-][0-9]{1,2}$
00.000.000-0
00.000.000-00
0.000.000-0
0.000.000-00
  Chile
RUT
^\d{1,2}\.\d{3}\.\d{3}[-][0-9kK]{1}$
00.000.000-0
00.000.000-X
0.000.000-0
0.000.000-X
Phone Number ^\+?569 ?[0-9]{8}$
+569 00000000
  Colombia
CC
^\d{1,2}\.\d{3}\.\d{3}$
00.000.000
0.000.000
  Ecuador
CI
^\d{9}\-\d{1}$
000000000-0
  Egypt
بطاقة تحقيق شخصية
Personal Verification Card
[A-Z,a-z]{2}[0-9]{7}
XX0000000
xx0000000
  India
Aadhaar Card
^\d{4}\ \d{4}\ \d{4}$
0000 0000 0000
  Mexico
IFE
[A-Z]{6}[0-9]{8}[A-Z]{1}[0-9]{3}
XXXXXX00000000X000
Phone Number
^([+]?52[ ]1[ ])?[0-9]{2} [0-9]{4} [0-9]{4}$
+52 1 00 0000 0000
52 1 00 0000 0000
00 0000 0000

  Spain
DNI
[0-9]{8}[A-Z]{1}
00000000X
  USA
SSN
^\d{3}\-\d{2}-\d{4}$
000-00-0000
Phone Number ^\+?1? ?[0-9]{3} [0-9]{3} ([0-9]{4}$
+1 000 000 0000
000 000 0000
  Venezuela
CI
^\d{1,2}\.\d{3}\.\d{3}$
00.000.000


Another Useful RegEx


RegEx
RegEx Match
Date
^((0?[13578]|10|12)(-|\/)(([1-9])|(0[1-9])|([12])([0-9]?)|(3[01]?))(-|\/)((19)([2-9])(\d{1})|(20)([01])(\d{1})|([8901])(\d{1}))|(0?[2469]|11)(-|\/)(([1-9])|(0[1-9])|([12])([0-9]?)|(3[0]?))(-|\/)((19)([2-9])(\d{1})|(20)([01])(\d{1})|([8901])(\d{1})))$
M/D/YY
M/D/YYY
MM/DD/YY
MM/DD/YYYY

Was this article helpful?