Field Validation
Validation ensures that entered data meets your criteria before submission.
Automatic Validation
Some modules have built-in validation:
| Module | Automatic Validation |
|---|---|
| Valid email format | |
| Phone | Valid phone format |
| IBAN | IBAN check key |
| Date | Valid date |
| Number | Numeric value |
Required Field
The most common parameter:
- Open the module settings
- Enable "Required"
- The user cannot continue without filling it
Visual Indicator
Required fields are marked with a red asterisk (*).
Validation Rules
Text Length
For text fields:
| Parameter | Description |
|---|---|
| Minimum | Minimum number of characters |
| Maximum | Maximum number of characters |
Example: French postal code
- Minimum: 5
- Maximum: 5
Numeric Values
For number fields:
| Parameter | Description |
|---|---|
| Minimum | Minimum accepted value |
| Maximum | Maximum accepted value |
| Decimals | Number of digits after decimal point |
Example: Percentage
- Minimum: 0
- Maximum: 100
- Decimals: 2
Dates
For date fields:
| Parameter | Description |
|---|---|
| Minimum date | Cannot be before |
| Maximum date | Cannot be after |
| Allowed days | Exclude weekends, holidays |
Example: Appointment date
- Minimum: today
- Maximum: +30 days
- Exclude: Saturdays, Sundays
Files
For uploads:
| Parameter | Description |
|---|---|
| Accepted types | Allowed extensions |
| Maximum size | In MB |
| Number of files | Min/max for multiple upload |
Example: ID document
- Types: PDF, JPG, PNG
- Max size: 10 MB
Regular Expression (Regex)
For advanced custom validations:
Common Examples
French postal code:
regex
^[0-9]{5}$SIRET number:
regex
^[0-9]{14}$License plate:
regex
^[A-Z]{2}-[0-9]{3}-[A-Z]{2}$Configuration
- Open the text module settings
- In "Advanced validation", add the expression
- Define the custom error message
Error Messages
Default Messages
Formulr displays appropriate messages:
- "This field is required"
- "The email address is not valid"
- "The value must be between X and Y"
Custom Messages
For each rule, you can customize the message:
- In validation settings
- "Error message" field
- Enter your text
Example:
"Please enter a French postal code with 5 digits"
Server-side Validation
In addition to browser-side validation, Formulr verifies:
- All rules at submission
- Integrity of uploaded files
- Data consistency
Security
Don't rely solely on client-side validation. Server validation is always enforced.
Best Practices
1. Be Explicit
- Indicate the expected format in the placeholder
- Use help text for complex cases
2. Clear Messages
- Explain how to correct the error
- Avoid technical jargon
3. Don't Over-validate
- Accept common formats
- Avoid overly restrictive rules
4. Test
- Try boundary values
- Verify error cases
Next Steps
- Module Types - All available modules
- Conditional Logic - Dynamic display