Form Validation
KwesForms provides 49 form validation rules that validate fields on the frontend and backend at the same time. This feature saves developers countless hours of validation work, improves UX, conversion rate, and helps fight spam.
How to Use
A list of all validation rules can be found on the next section of the docs, form validation rules.
To use a form validation rule, simply add a rules
attribute on your field and follow the syntax for the validation rule. Here is a sample code using the numeric validation rule.
<input type="text" rules="numeric">
<input type="text" data-kw-rules="numeric">
Multiple validation rules
All form validation rules can be combined with one another to satisfy a validation requirement. To combine rules use the pipe character |
between rules. Validation rules are processed in the order it's written from left to right.
<input type="text" rules="required|numeric">
<input type="text" data-kw-rules="required|numeric">
Behavior
Heres an example of a field with some validation rules. Notice how it validates on the frontend 3 different ways:
- As you type
- When you click out of the field
- When you press submit
<input name="name" rules="required|min:3|max:20">
<input name="name" data-kw-rules="required|min:3|max:20">
Notice anything wrong in our docs? Let us know.