Skip to main content
Text field validation
M
Written by Marya Maksimchuk
Updated over a week ago

Availability: Essentials, Business, and Enterprise plans

With this feature, we’ll help you make sure your recipients’ input information in fields always appears in the correct format.

Note:

You can set field validation only in text fields.

You can set these field formats in a text field:

To enable one of these formats in a text field, first, add a text field to your document or template. Then, click on the field properties icon and go to the setting on the right panel. Under Validation, select one of the formats.

If information appears in a field in an incorrect format, and the document is still in draft status, the document can’t be sent until the format has been corrected.

If the recipient has entered invalid information, they won’t be able to finish the document. Any fields with invalid inputs will be indicated.

mceclip6.png

Custom rule (regular expression)

You can use custom rules to create validation patterns via regular expressions (a.k.a. regex).

Regular expressions provide a powerful tool for validating text fields. By defining patterns, you can enforce specific rules and restrictions on recipients’ input.

To create a custom rule, first determine the specific requirements for your text field validation. For example, you might want to validate that the input contains only letters, numbers, or a specific set of characters. Identify any length restrictions or specific patterns you want to enforce.

Based on your requirements, create the regular expression pattern that matches the desired input. For example, if you want to validate that the input consists of letters and numbers, the pattern could be [A-Za-z0-9]+.

Follow these steps to enable custom validation for a text field:

  1. Add a text field in a document, template, content library item, or form

  2. Select Properties on the floating panel and select Custom rule (regular expression) in the Validation dropdown

  3. In the Custom rule pattern field, enter the regular expression that defines the data format you'd like your recipient to input

  4. In the Recipient instructions field, provide details that help your recipients to enter the correct information

  5. Enable the Required setting, then send the document

Once you send your document, the recipient will be able to finalize it only if they enter valid information. If they provide information in an incorrect format, the field will be highlighted in red.

Regular expressions can be complex, and their implementation might require knowledge of specific regex features and options. Learn more about regular expressions here.

Examples of regex validation patterns

Here are several examples of regex validation patterns:

Canadian Social Insurance Number (SIN)

  • Pattern: ^\d{3}(\s?|[-]?)\d{3}(\s?|[-]?)\d{3}$

  • Description: Validates Canadian Social Insurance Number. Accepted values are 123123123, 123 123 123, or 123-123-123.

US state abbreviations

  • Pattern: (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])

  • Description: Validates US state postal abbreviations (two letters, always capitalized, without periods).

UK National Insurance Number (NINo)

  • Pattern: [A-CEGHJ-PR-TW-Z]{1}[A-CEGHJ-NPR-TW-Z]{1}\s?[0-9]{2}\s?[0-9]{2}\s?[0-9]{2}\s?[A-DFMP ]

  • Description: Validates UK National Insurance Number. A NINo is comprised of two letters, six numbers, and a final letter, always A, B, C, or D. It looks like this: QQ 12 34 56 A.

International Bank Account Number (IBAN)

  • Pattern: ^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$

  • Description: Validates International Bank Account Number (IBAN), a standardized format used by most European countries. The format consists of letters and numbers and has a fixed length of up to 34 characters.

All capital letter

  • Pattern: ^[A-Z]+$

  • Description: Validates all characters to be capital letters.

Date format: MM/YYYY

  • Pattern: ^(0[1-9]|1[0-2])\/\d{4}$

  • Description: This regex ensures the input is in the MM/YYYY format, with a valid month and a four-digit year.

Four digits only

  • Pattern: ^\d{4}$

  • Description: Restricts input to exactly 4 digits.

Did this answer your question?