FAQs: Regex in layout and validation rules | Zoho Desk

FAQs: Regex in layout and validation rules

Regex basics

What is regex?
Regex, or regular expression, is a pattern-matching method used to check whether text entered in a field follows a required format. It can be used in layout rules and validation rules to control how users provide information.

For example, a rule can require an order number to contain only alphanumeric characters, such as ORD123, rather than allowing unrelated symbols or formats.
Which regex comparisons are available?
Zoho Desk provides three regex comparison options:
  1. Matches Regex - checks whether the entered value matches the specified pattern.
  2. Not Matches Regex - checks whether the entered value does not match the specified pattern.
  3. Contains Regex - checks whether the entered value contains text matching the specified pattern.
Choose the comparison that reflects the intended business rule. For example, use Matches Regex when an entire field must follow one prescribed format.
Can a custom regex pattern be created?
Yes. Administrators can enter a custom regex pattern rather than relying only on predefined patterns. A custom pattern can include alphanumeric characters and be tailored to the field’s required format.

This is useful where an organization has its own identifier convention, such as a product code or reference number format.


Using regex in validation rules

How can a regex-based validation rule be created?
  1. Navigate to Setup > Customization > Layouts and Fields > Validation Rules.
  2. Select the required:
    1. Module
    2. Department
  3. Click Create Rule.
  4. Select the relevant layout and field.
  5. Click Add Option to define the primary condition.
  6. Select the required regex comparison:
    1. Matches Regex
    2. Not Matches Regex
    3. Contains Regex
  7. Enter the required pattern in Custom Pattern.
  8. Click Done, then Save.
When a submitted value does not meet the defined criteria, Zoho Desk displays the configured alert message.


Can regex be used in secondary conditions of a validation rule?
No, Regex is supported only in the primary condition of a validation rule. Secondary conditions can be used to determine when the primary-field validation applies, but they cannot use regex criteria.

For example, a Phone Number field can be the primary field checked with a regex pattern, while Country can be used as a secondary condition to apply that validation only when the selected country is India.
Can more than one validation rule be created for the same primary field?
No, Only one validation rule can be created for a particular primary field. This prevents overlapping rules from applying conflicting requirements to the same input.

If a field must follow different rules in different circumstances, use secondary conditions within the same validation rule to define when each requirement applies.
How can a field be limited to numeric values only?
Create a validation rule using the numeric-only pattern and the Not Matches Regex comparator. If users enter letters or other unsupported characters, the configured alert message is displayed.

For example, an Account Number field can be configured to reject AC12345 and prompt the user to enter digits only, while accepting a value such as 123456789.
Can an alert message be displayed when a regex validation fails?
Yes. Each validation rule can include an alert message that tells the user what must be corrected. The alert-message limit is 150 characters.

Use a direct message that explains the required format. For example: “Enter an account number using digits only.”


Regex in layout rules

Can regex be used to trigger a layout rule?
Yes. Layout rules can use Matches Regex, Not Matches Regex, and Contains Regex as criteria. This allows the layout to respond to the format of a user’s entry.

For example, a layout rule can display a Billing Details section after a user enters an Order Number that matches the organization’s required alphanumeric format.
Can regex be used with multi-select picklist fields in layout rules?
Layout rules can use multi-select picklist fields, and they can also use regex criteria. These are separate supported capabilities for layout rules.

For example, a layout rule can display billing-related fields when a customer selects relevant values in a Service Topics multi-select picklist. A different rule can use regex to evaluate whether an Order Number follows the intended format.
Do regex validation rules apply to tickets submitted through the Help Center?
Yes, provided that Apply to Help Center is selected while creating the validation rule. This applies the configured validation to tickets submitted through the Help Center as well as to tickets created by agents in Zoho Desk.

For example, a customer submitting a ticket can be required to provide an account number in the expected format before the ticket is accepted.