Form Element Validation

Issue/Question

How do I ensure that a single-line or multi-line text form element matches a specified format?

Environment

  • Omni CMS

Resolution

Use the Validation attribute on Single-Line Text and Multi-Line Text elements to specify that additional requirements be met.

  1. Edit the form asset to add validation to.
  2. Locate the existing Single-Line or Multi-Line Text element or add a new one by dragging and dropping or clicking it in the Form Elements panel.
  3. Check the Required checkbox, this is necessary to enable additional validation.
  4. Use the Validation dropdown and select an option.
    • Email - Ensures that the text entered is a valid email address. (Please Note: this will not validate that it is a WKU or TopperMail address)
    • Minimum Length - Validates that the text entered meets a minimum number of characters.
    • Regular Expression - Uses the Regular Expression to specify a pattern that must be matched.
      • To validate a phone number with the following layout xxx-xxx-xxxx you would need to enter ^(\d){3}-(\d){3}-(\d){4}$
      • To validate for a WKU email address you would enter the following: ^([A-Za-z0-9\.-]+@wku.edu)|([A-Za-z0-9\.-]+@topper.wku.edu)$
      • To validate for a WKU ID (800 number) you will enter the following: ^(800|801)+(\d){6}$ you can also validate with ^(\d){9}$  it will allow 9 digits if you need more than just 800 in the front of the number.
      • To validate a date with the following format MM/DD/YYYY you would enter the following: ^([0-9]|0[0-9]|1[0-2])\/(0[0-9]|[1-2][0-9]|3[0-1])\/[0-9]{4}$
  5. If using Minimum Length or Regular Expression enter you number or expression in the coordinating field that appears.
  6. Add a Failure Message to display if the user does not pass the selected validation.
  7. Save and Publish the form asset to make all changes live.
Print Article

Details

Article ID: 3911
Created
Fri 2/11/22 8:23 AM
Modified
Thu 10/26/23 2:00 PM