Skip to main content
Editor Form Validation

How to Guide Recipients to Enter Well-Formatted Data Using Regular Expressions

Updated today

Introduction

When creating forms in GetAccept, it’s important to guide recipients in entering well-formatted data. Consider using specialized input fields, such as dates, emails, checkboxes, or option lists, which will automatically validate the data for you. If none of these input types meet your needs, and you require a free text field, this article will walk you through using regular expressions (RegEx) for validating the input.


Creating a New Field with RegEx

  1. Create an Editor Block: Start by creating an editor block where you want the text input field.

  2. Add a Text Input Field: Click the blue [ + ] symbol inside the block, scroll down, and select the Text input field from the Engagement elements list.

  3. Set Up Validation:

    • In the context menu, click the settings icon.

    • Select the Set up RegEx validation option.


Note:

  • In the field settings menu, you can also set minimum and maximum input lengths. If this is sufficient validation, you can skip the RegEx setup.

  • You can also mark the field as required, which ensures the recipient or sender cannot complete or sign the document without providing valid input.



Setting Up Your RegEx Validation

The RegEx validation setup allows you to create customized validation rules for your text input fields. The modal includes fields for entering your RegEx pattern, custom error message, and a test area to validate your input.

The RegEx Field

This is where you input the regular expression that will validate the user’s input. The entered expression will be matched against the entire input. If the expression matches, the input will be considered valid. If it doesn’t match, the input will be flagged as invalid.

  • If you enter an invalid RegEx, an error message will appear to help you correct it.

Common Regular Expressions

Here are some useful RegEx patterns that you can copy and paste directly into the field:

  • Street address [a-zA-Z\d\s\-\,\#\.\+]+

  • Phone number (international) ^\s*(?:\+?(\d{1,3}))?([-. (]*(\d{3})[-. )]*)?((\d{3})[-. ]*(\d{2,4})(?:[-.x ]*(\d+))?)\s*$

  • Email [a-zA-Z0-9_\.\+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-\.]+

  • Date (dd/MM/yyyy) ((0[1-9])|(1[0-2]))[\/-]((0[1-9])|(1[0-9])|(2[0-9])|(3[0-1]))[\/-](\d{4})

  • Date (yyyy-MM-dd) ^\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])$

  • Only numbers ^[\d\s]+$

  • Phone number (US) ^(?:\(\d{3}\)|\d{3})(?: *- *)?\d{3}(?: *- *)?\d{4}$

  • Website ^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$

  • Zip Code (US) ^([0-9]{5}(?:-[0-9]{4})?)*$

  • State (US) ^(?:A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])*$

  • US Social Security Number / Canadian Social Insurance Number ^(\d{3}-\d{3}-\d{3})|(\d{3}-\d{2}-\d{4})$


The Custom Error Field

This is where you enter the error message that will appear if the recipient or sender inputs invalid data. Make the message clear and instructive so users understand what they need to correct.

Example: If validating for an email address, the error message might read: "Please enter a valid email address, e.g., example@domain.com."


The Test Field

Before saving your settings, test your regular expression in the test field. Enter various inputs to ensure the RegEx works as expected. Testing helps prevent invalid inputs from slipping through and ensures recipients can easily comply with the form’s requirements.


Using Minimum and Maximum Field Lengths

If you don't require RegEx validation but still need basic input control, you can set minimum and maximum character limits directly from the field settings:

  • Minimum Length: This ensures the user enters at least the required number of characters.

  • Maximum Length: This restricts the input to a maximum number of characters.

Example: A phone number field might require a minimum of 10 characters and a maximum of 15.

Did this answer your question?