Form-Level Validation
Form-level validation involves rules that span multiple components or apply to the form as a whole. These validations help ensure data consistency and integrity across the entire form.
Common Form-Level Validations
- Conditional Validation: Make fields required based on other field values
- Cross-Field Validation: Compare values between different fields
- Unique Value Validation: Ensure certain fields have unique values across submissions
Conditional Validation
Conditional validation makes a field required or applies other validation rules based on the values of other fields. For example:
- Making an "Other" text field required when "Other" is selected in a dropdown
- Requiring additional details when a certain option is chosen
- Applying different validation rules based on the form context
To configure conditional validation:
- Select the component on the canvas
- Navigate to the Validation tab in the settings panel
- Enable the "Conditional Validation" option
- Set up the condition using the visual condition builder:
- Select the field to base the condition on
- Choose the operator (equals, not equals, contains, etc.)
- Specify the value to compare against
- Configure the validation rule to apply when the condition is met
- Customize the error message
Cross-Field Validation
Cross-field validation compares values between different fields to ensure consistency. Common examples include:
- Ensuring a "Confirm Password" field matches the "Password" field
- Verifying that an end date is after a start date
- Checking that a maximum value is greater than a minimum value
To configure cross-field validation:
- Select the component on the canvas
- Navigate to the Validation tab in the settings panel
- Enable the "Cross-Field Validation" option
- Select the field to compare with
- Choose the comparison operator (equals, not equals, greater than, etc.)
- Customize the error message
Unique Value Validation
Unique value validation ensures that certain fields have unique values across all submissions. This is useful for fields like:
- User IDs
- Serial numbers
- Registration codes
- Email addresses (when used as identifiers)
To configure unique value validation:
- Select the component on the canvas
- Navigate to the Validation tab in the settings panel
- Enable the "Unique" option
- Customize the error message
When a user attempts to submit a form with a value that already exists in a previous submission, an error message will be displayed.
Custom JavaScript Validation
For advanced validation needs, you can use custom JavaScript to implement complex validation logic:
- Select the component on the canvas
- Navigate to the Validation tab in the settings panel
- Enable the "Custom Validation" option
- Enter JavaScript code that returns true (valid) or false (invalid)
- Customize the error message
Custom JavaScript validation provides the most flexibility for implementing complex validation rules that cannot be achieved with the standard validation options.