search ESC

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.

⊗ Please enter a valid email address
✓ Username is available
⚠ Password is weak, consider adding special characters
ⓘ We'll send a verification code to this number
Neutral (default) state
Include country code when dialing internationally.
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.

Must be at least 8 characters.
Built-in validation rules
RuleSyntaxChecks
requiredrequiredValue is not empty
emailemailValid email format
urlurlValid URL format
numericnumericNumeric string
alphaalphaLetters only
phonephonePhone number format
minmin:8Minimum length / numeric value
maxmax:100Maximum length / numeric value
patternpattern:^[a-z]+$Matches a regex
matchmatch:passwordEquals 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
ClassPurpose
.lp-form-group--errorRed border + tinted label; reveals .lp-form-group-error
.lp-form-group--successGreen border + tinted label; reveals .lp-form-group-success
.lp-form-group--warningAmber border + tinted label; reveals .lp-form-group-warning
.lp-form-group--infoBlue 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-helpMuted 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.