Customizable User Field Validation Messages

As an Admin, you can customize the error messages that appear to Users on default user fields and Custom Fields. These messages appear when a value doesn't match the Custom Regex added to a field, which helps you validate or restrict the information gathered from your Users. This article explains where validation messages appear, how to add a regex to a field, and how to configure the message text.

 

Areas Used

Customizable validation messages appear on the following pages in the Learner Experience:

  • Enrollment Key sign-up page.
  • E-Commerce sign-up page during checkout.
  • E-Commerce subscription seat sign-up page.
  • E-Commerce shipping address page.
  • E-Commerce billing page (Custom Fields only).
  • My Profile page, when a User edits their profile.

 

The same validation message is displayed across all of these pages, based on the regex and translation term values provided.

Validation in the Admin Experience

Custom regex validation applies only in the Learner Experience. When an Admin creates or edits a User in the Admin Experience, field values are not checked against the field's Custom Regex, so values that don't match it can still be saved.

 

Configuring Validation Messages

Configuring a validation message involves two components:

  1. Adding a regex value to a User field, which validates the field when a User enters a value.
  2. Configuring the validation message that is displayed to the User.

 

Adding a Regex (Regular Expression) Validation to a Field

An Admin can add a Custom Regex from Portal Settings. Use the User Profile tab for default user fields, and the Custom Fields tab for Custom Fields. Every default user field supports a Custom Regex, but for Custom Fields, it is available only on fields with a Type of Text.

The Custom Regex is always treated as a regular expression, which gives you flexibility to require a specific response or restrict a field to text only, numbers only, and so on. Keep the following in mind when writing a regex:

  • Matching is case-sensitive.
  • A value passes if any part of it matches the regex. For example, a regex of Calgary also accepts "North Calgary". To require an exact value, start the regex with ^ and end it with $.
  • Characters such as ., +, (, ), and * act as pattern symbols rather than plain text.

 

For example, a Custom Regex could be added to the City field with either of the following:

  • ^Calgary$: accepts only the exact value "Calgary".
  • ^[a-zA-Z]+(\s[a-zA-Z]+)?$: accepts letters only, with an optional single space between two words, such as "Red Deer".

 

How Field Behaviour Affects Validation

The Behaviour setting on a field also determines when the validation is checked:

  • Hidden: The field is not validated.
  • Read Only and Locked: Users can't edit the field, but a prefilled value that doesn't match the regex still displays the validation message.
  • Required: An empty field displays a required-field message. Once the User enters a value, the validation is checked.
  • Optional: The validation is checked only if the User enters a value.

 

Fields That Require Special Attention

For drop-down fields, the regex is checked against the value submitted by the drop-down rather than the text the User sees. The following fields require special attention:

  • Country (drop-down): Use the two-letter country code, such as CA for Canada. Note the case used. A link to the full list of codes is in the Appendix at the end of this article.
  • Province/State (drop-down): Use the full name of the province or state to match a value in the drop-down, such as "California" or "British Columbia". Note the case used.
  • Language (drop-down): Use the language code, such as en for English. Note the case used. A link to the full list of codes is in the Appendix at the end of this article.
  • Text-based Custom Field (text or drop-down):
    • If the field has a Values list, Users select from a drop-down, and the regex is checked against the text of the selected list value.
    • If the field allows User entry, the regex can be a word, such as ^Red$, or a pattern, such as one for a UK cell phone number.

 

Adding a Validation Message Term Value

Each validation message combines two translation terms: a generic message displayed in all error cases, followed by a field-specific term that provides the error details for that field. Both terms are edited from Setup > Translations in the Admin Experience by System Admins or Admins with permission to modify Translations. For more information, see Viewing, Adding, and Editing Translations.

The format for the field validations is FieldValidationMessage followed by the field's details term.

Please note: The field details terms are blank by default in every language. A value added for one language does not apply to Users who view the LMS in another language, so add a value for each language your Users use.

 

FieldValidationMessage

This term contains the generic message displayed for every field that fails validation:

  • The default English value is "{0} does not meet minimum requirements:", where {0} is replaced with the label of the field that failed validation. For Custom Fields, {0} is the field's Name as configured in Portal Settings.
  • You can customize this value to fit your needs. To keep the field name in the message, include {0} somewhere in the value.
  • If the field's details term is blank, the message ends at the colon.

 

Field Details Terms

Each field that accepts a Custom Regex has its own details term:

  • Default user field terms use the format FieldNameValidationDetails, such as FirstNameValidationDetails, LastNameValidationDetails, and PhoneValidationDetails.
  • Custom Field terms use the format CustomFieldString followed by a number, such as CustomFieldString1. The number matches the storage slot shown next to the field's Name on the Custom Fields tab after the field is saved.
  • The value for each of these terms is blank by default, so you can add your own validation message when a regex is entered.
  • The translation values can include special characters.
  • A full list of fields that allow customized validation messages is included in the Appendix at the end of this article.

 

Example Validation: Phone Number

A regex for a phone number could be ((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}. This requires a dash in the last seven digits, with an optional area code in brackets or followed by a dash.

Phone number regex entered in the Custom Regex field

 

The PhoneValidationDetails term value could then be "###-###-#### or (###) ###-####."

PhoneValidationDetails term value in Translations

 

If a User enters a phone number of 4035551234, the following message is displayed: "Phone Number does not meet minimum requirements: ###-###-#### or (###) ###-####." The validation message is displayed below the field in question.

Validation message displayed below the Phone Number field

 

Appendix

This section lists the translation terms and codes referenced in this article.

 

Fields with Custom Validation Messages

The following terms allow custom validation messages. Expand each section to view the full list.

Default User Fields

  • Address2ValidationDetails
  • AddressValidationDetails
  • CityValidationDetails
  • CountryValidationDetails
  • EmailAddressValidationDetails
  • EmployeeNumberValidationDetails
  • FirstNameValidationDetails
  • JobTitleValidationDetails
  • LanguageValidationDetails
  • LastNameValidationDetails
  • LocationValidationDetails
  • MiddleNameValidationDetails
  • PasswordValidationDetails
  • PhoneValidationDetails
  • PostalCodeValidationDetails
  • ProvinceValidationDetails
  • UsernameValidationDetails
  • VerifyPasswordValidationDetails

 

Custom Fields

  • CustomFieldString1
  • CustomFieldString2
  • CustomFieldString3
  • CustomFieldString4
  • CustomFieldString5
  • CustomFieldString6
  • CustomFieldString7
  • CustomFieldString8
  • CustomFieldString9
  • CustomFieldString10
  • CustomFieldString11
  • CustomFieldString12
  • CustomFieldString13
  • CustomFieldString14
  • CustomFieldString15
  • CustomFieldString16
  • CustomFieldString17
  • CustomFieldString18
  • CustomFieldString19
  • CustomFieldString20
  • CustomFieldString21
  • CustomFieldString22
  • CustomFieldString23
  • CustomFieldString24
  • CustomFieldString25
  • CustomFieldString26
  • CustomFieldString27
  • CustomFieldString28
  • CustomFieldString29
  • CustomFieldString30

 

Country Codes

The Country field uses two-letter ISO 3166-1 alpha-2 codes, which must be uppercase. For the full list, see ISO 3166-1 alpha-2 Officially Assigned Code Elements.

 

Language Codes

When adding a Custom Regex to the Language field, use the code listed in the Abbreviation column of Language Codes for Absorb. Language codes are case-sensitive. Most are lowercase, such as en or pt-br, but some regional variants include uppercase letters, such as fr-CA.

 

More Information

For more information about the features referenced in this article, see the following articles:

 

Was this article helpful?
0 out of 1 found this helpful

Comments

0 comments

Please sign in to leave a comment.