Validation
> Ensure form submissions contain clean, correctly formatted data.
Brickr forms support built-in validation rules that run before a submission is accepted. If validation fails, the user sees an error message next to the offending field.
Required fields
Mark any field as required to ensure the user provides a value before submitting.
1. Select a field in the form builder. 2. Toggle the Required option on. 3. Optionally customize the error message.
When a required field is left empty, the form will not submit and the field will be highlighted.
Hidden fields can also be marked as required. If no default value is set, the submission will fail -- this is useful for fields that must be populated programmatically.
Min and max rules
Numeric and text fields support minimum and maximum constraints.
For number fields
- Min -- The lowest accepted value
- Max -- The highest accepted value
For example, a quantity field might have min=1 and max=100.
For text fields
- Min length -- Minimum number of characters
- Max length -- Maximum number of characters
For range fields
- Min and Max are set during field configuration and define the slider's bounds
- Step controls the increment between values
Format validation
Some field types have automatic format validation:
| Field Type | Validation | |-----------|-----------| | Email | Must be a valid email address | | URL | Must be a valid URL | | Phone | Must match phone number format | | Number | Must be a numeric value |
These validations run automatically -- no extra configuration needed.
File validation
File and image fields support:
- Accepted types -- Restrict which file extensions are allowed
- Max size -- Maximum file size in megabytes
- Multiple -- Whether to accept one or multiple files
Always configure accepted file types for file upload fields. Leaving them unrestricted could allow users to upload unexpected file formats.
Custom validation rules
For more complex scenarios, you can add custom validation using pattern matching:
- Regex pattern -- A regular expression the value must match
- Custom error message -- The message shown when validation fails
For example, to ensure a text field only accepts alphanumeric characters:
| Setting | Value | |---------|-------| | Pattern | ^[a-zA-Z0-9]+$ | | Error message | "Only letters and numbers are allowed" |
Validation behavior
When a user submits a form:
1. All required fields are checked for values. 2. Format validation runs on typed fields (email, URL, phone). 3. Min/max constraints are evaluated. 4. Custom patterns are tested. 5. If any rule fails, the form shows error messages and blocks submission. 6. If all rules pass, the submission is accepted and stored.
Test your validation rules using the form preview before sharing the form publicly. This helps catch overly strict rules that might frustrate users.
What's next?
| Topic | Description | |-------|-------------| | Submissions | View and manage collected responses | | Triggers | Automate actions when forms are submitted | | Field Types | Explore all available field types |