TABLE OF CONTENTS
Form validation is important to ensure that the data entered by users is accurate and meets the required criteria before submission. Properly configured validation rules prevent incorrect data entries and guide users to input the correct information. This article will guide you through the process of configuring form validation Rules for your App.
Configuring Form Validation Rules
This section provides instructions for configuring a validation rule for your form. When configuring form validation, there are two approaches: the standard approach and the advanced approach. The standard approach involves using standard validation conditions based on the field type. For more complex cases, the advanced approach allows you to define custom validation logic using expressions.
Standard Form Validation
Standard Validation covers the standard set of rules that are straightforward to configure and require no coding. With Standard Validation, you can set conditions like whether a field is present, restrict input length, check for specific text within a field, and more.
To configure a validation Rule:
- Navigate to the Design editor.
- In the Explorer menu of the Explorer and Components Panel select the Form Component or click the required Component in the Canvas.
- In the Appearance and Configuration Panel, select Configuration.
- Scroll down to the Form validation section, then click the Configure validation Rules button to open the Validations dialogue.
- Click the plus (+) icon in the left panel of the Validations dialogue to add a new Rule.
- Fill in the following details:
Name: Enter a name for the validation rule.
Field: Select the field to apply the validation rule to. This is mandatory for saving the rule.
Condition: Define the condition that must be met for validation to pass.
Based on the values for the Field and Condition values, additional fields may appear for configuration.
Field error text: Enter the error message that will appear when hovering over the validation field and any other fields specified in the Show this message on fields list. If left blank, the invalid form input will still be highlighted, but no message will appear.
Form error text: Enter the error message that will appear on the form if validation fails.
- Click Save to apply the rule. If a red asterisk appears next to the rule name, it indicates that the rule hasn't been saved or is invalid. Resolve any issues before saving.
Note: If you are editing multiple rules at once, ensure that all rules are properly configured. You won't be able to save changes if any rule remains incomplete or invalid.
Example 1
The screenshot below illustrates a scenario where a user attempts to submit the Spacecraft Search form with invalid data. The form includes two validation rules: one checks whether the Name field is specified (is present), and the other ensures that the Flight Count field contains a numeric value. The highlighted fields indicate errors, as the validation rules have not been met.
Advanced Form Validation
You can achieve more advanced validation using custom expressions. This approach allows you to define complex conditions that go beyond standard options. For more detailed information on expressions, refer to the Understanding mustaches and expressions article.
To add a custom expression:
- Refer to the earlier Standard Form Validation section on configuring validation rules to follow the initial steps and fill in the standard fields like Name and Error texts.
- In the Validations dialogue, click the 'fx' icon next to the Condition field to enable the advanced mode, which allows you to input a custom mustache expression.
- Enter your custom expression.
- After specifying the Field error text, make sure you assign the field where the error message should be displayed.
- Click Save to apply the rule.
Example 2
The screenshot below illustrates a scenario where a user attempts to submit the Spacecraft Search form with invalid data. The form includes a validation rule with an expression as a condition that checks whether the Status field is set to "active." The highlighted fields indicate an error, as the validation rule has not been met.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article