Building with AI?
llms.txt
The Basics
Simple validation and error display using sf-validate and if-error directives.
Live Demo
Source Code
How It Works
- 1. Add validation rules to inputs
Use
sf-validate:rule="Error message"Stack multiple rules:
sf-validate:required sf-validate:email - 2. Show error messages
Use
if-error="field" then-show-textto display validation errorsAdd
else-hideto hide when valid - 3. Style inputs on error
Use
error-class="classes"directly on inputs
Note: Use style="display:none" on error elements to hide them until the form engine loads.
Common Validation Rules
-
sf-validate:required- Field must have a value -
sf-validate:email- Valid email format -
sf-validate:url- Valid URL format -
sf-validate:min[5]- Minimum value (numbers) or length (text) -
sf-validate:max[100]- Maximum value or length
See Advanced Validation for more rules.