A regular expression - or REGEX, for short - is an extremely flexible syntax that allows you to define a specific pattern for a string. These can be applied to standard or custom registration fields in the Contact Information or Attendee Information forms sections of an Event registration to limit the values that can be input into a field.
To apply this to standard fields
- Go to the "Customize Headings and Labels" section
- Find the corresponding label (email, phone, etc.)
- Make sure the Expected Input format is set to "Regular Expression"
- Enter the syntax into the Regular Expression field
- Save
Here are some common examples of regex for form field validations as created by ChatGPT which can be a helpful resource for creating REGEX based on a human language prompt that you give it.
1. Email
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
This regex checks if the input is a valid email address by matching a pattern that consists of a username part, followed by the @ symbol, a domain name, and a top-level domain name. It allows letters, numbers, and certain special characters in the username and domain name, and requires at least two letters in the top-level domain name.
2. Phone number
^\+?\d{1,3}[- ]?\d{3,4}[- ]?\d{4}$
This regex checks if the input is a valid phone number, with or without a country code prefix (+). It allows digits and optional spaces or hyphens between the groups of digits.
3. URL
^(https?:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$
This regex checks if the input is a valid URL that starts with optional HTTP or HTTPS protocol, followed by a domain name, and optional port number and path. It allows lowercase letters, digits, and hyphens in the domain name, and supports subdomains and query strings.
For more details on using REGEX in the Events app, check out these articles:
- Customizing field validation requirements for custom Salesforce fields in the Attendee Information section of an Event registration
- Customizing field validation requirements for custom Salesforce fields in the Contact Information section of an Event registration
- Customizing field validation requirements for standard fields in the Attendee Information section of an Event registration
- Customizing field validation requirements for standard fields in the Contact Information section of an Event registration