Issue
- You want to create validation for a fragment's text field
- When trying to validate a fragment's text field using Freemarker, it is not executed in the published editable field
- The validation only works on the default value in the page editing view, but not on the final field after publishing
Environment
- Liferay DXP 7.4
Resolution
Note: For this resolution, the text field has to be linked to a customObject.
- Go to Control Panel > Objects > customObject > Validations > “+”
- Give it a name and choose “Expression Builder” as Type > Save
- Go to your "testValidation" > Set “Active Validation” to True
- Go to "Conditions" and enter your RegEx validation rule.
- Enter an error message of your preference
- Save
- Now, your text field's contents are validated upon submitting through the Objects framework.