On this page
Form & Validation Attributes
Prev: Global Attributes | Up: attributes | Next: ARIA & Accessibility Attributes
Rel: Forms & Inputs, Accessible Forms & Validation, Forms, Validation & Fetch
Ref: MDN Web Docs — Client-Side Form Validation
Tags: #public #web #html #attributes #forms
Contents
Built-in Constraint Attributes
| Attribute | Applies To | Behavior |
|---|---|---|
required |
inputs, select, textarea | Field must have a value before submit |
min / max / step |
number, range, date |
Numeric/date bounds and increments |
minlength / maxlength |
text-like inputs | Character length bounds |
pattern |
text-like inputs | Full-value JavaScript RegExp (implicitly anchored ^(?:...)$) |
novalidate |
<form> |
Disables native browser popups so JS handles validation UI |
<input
id="username"
name="username"
type="text"
required
minlength="3"
maxlength="20"
pattern="[a-z0-9_]+"
autocomplete="username"
/>
UX & Autocomplete Attributes
autocomplete: Hints password managers and browsers (email,current-password,new-password,one-time-code,street-address).inputmode: Selects the optimal mobile virtual keyboard (numeric,decimal,email,tel,search) without changing validation rules.enterkeyhint: Customizes the mobile Enter key label (send,search,done,next).
Linked from
Related notes
- tuts/html/attributes Linked here; links to this page; shared tags: #attributes, #html, #web
- tuts/html/attributes/aria_and_accessibility_attributes Linked here; links to this page; shared tags: #attributes, #html, #web
- tuts/html/attributes/global_attributes Linked here; links to this page; shared tags: #attributes, #html, #web
- tuts/html/elements/forms_and_inputs Linked here; links to this page; shared tags: #forms, #html, #web
- tuts/html/tutorials/accessible_forms_and_validation Linked here; links to this page; shared tags: #forms, #html, #web
- tuts/web/tutorials/forms_validation_and_fetch Linked here; shared tags: #forms, #web
- tuts/html/elements/forms shared tags: #forms, #html, #web
- tuts/html/elements/forms/button shared tags: #forms, #html, #web
- tuts/html/elements/forms/datalist shared tags: #forms, #html, #web
- tuts/html/elements/forms/fieldset shared tags: #forms, #html, #web