Form Validation
Validation states, messages, and live validation via the FormController / Field components. Error and success states are applied to .lp-form-group and propagate styling to the child input.
Contextual states
Apply lp-form-group--{error|success|warning|info} on the wrapper. The matching message element (lp-form-group-{error|success|warning|info}) becomes visible, the label is tinted, and the input border — including on hover and focus — matches the state color.
Neutral (default) state
Hover & focus preview
Move your cursor over each of these fields to see the matching contextual hover border, then click to focus and see the matching focus ring.
Live validation (FormController)
Each field has data-lp-rules listing validation rules. The form validates on blur and on submit.
Built-in validation rules
| Rule | Syntax | Checks |
|---|---|---|
required | required | Value is not empty |
email | email | Valid email format |
url | url | Valid URL format |
numeric | numeric | Numeric string |
alpha | alpha | Letters only |
phone | phone | Phone number format |
min | min:8 | Minimum length / numeric value |
max | max:100 | Maximum length / numeric value |
pattern | pattern:^[a-z]+$ | Matches a regex |
match | match:password | Equals another field's value |
Separate multiple rules with |. Parameters follow a colon. Rules can also be registered programmatically via Validator.register(name, fn).
CSS reference
| Class | Purpose |
|---|---|
.lp-form-group--error | Red border + tinted label; reveals .lp-form-group-error |
.lp-form-group--success | Green border + tinted label; reveals .lp-form-group-success |
.lp-form-group--warning | Amber border + tinted label; reveals .lp-form-group-warning |
.lp-form-group--info | Blue border + tinted label; reveals .lp-form-group-info |
.lp-form-group-{error|success|warning|info} | Message element for each state (hidden by default) |
.lp-form-group-help | Muted hint text (auto-hidden when any state class is present) |
Hover and focus rings automatically pick up the state color — e.g. an input inside .lp-form-group--warning keeps its amber border on hover and gets an amber focus halo instead of the default primary blue.