Body
Issue/Question
How do I ensure that a single-line or multi-line text form element matches a specified format?
Environment
Resolution
Use the Validation attribute on Single-Line Text and Multi-Line Text elements to specify that additional requirements be met.
- Edit the form asset to add validation to.
- 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.
- Check the Required checkbox, this is necessary to enable additional validation.
- 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}$
- If using Minimum Length or Regular Expression enter you number or expression in the coordinating field that appears.
- Add a Failure Message to display if the user does not pass the selected validation.
- Save and Publish the form asset to make all changes live.