Form
Validation
A field should show validation errors as soon as the following rules are fullfild:
- if form was tried to submit
- if the field loses focus and the value is different from the initial value
Some validators can influence the shown errors as well as they follow specific rules when they have to be applied. Check out the section Validators.
Validators
Fields and forms can have different validators. There can be generic ones like required, max length and email address validators but there can be also use case specific validators like one that checkds that one field is greater than another field.
Form some validators we have rules how they have to be applied:
"Required" validator only applies as soon as the form was submitted. This hides annoying errors about required fields in case the user is in the process of editing the fields of the form. All fields which are required should have a visual indicator that the field is mendatory.
All validators except "required" should only validate values which have a non-empty value. This prevents that validation erros wil be shown because a missing value doesn't fullfil a specifc lenght or format.
Examples
Required email field
This example describes the states of a required email field over time.
- (Validators: email validator)
- User changes the value to an invalid email address
- Leaves the field
- Field shows that email address is not valid
- User enters the field and clears the value
- Field doesn't show an error
- User tries to submits the form
- (Validators: require validator, email validator)
- Field shows required error