HTML
html/input-type
An input for an email address, phone number or URL uses type email, tel or url, not text.
drobnastatycznefe-forms
Dlaczego
A plain text field gives a phone the letter keyboard for a phone number, no @ key for an email, and no built-in check of the format. The right type costs nothing and makes the field faster and less error-prone to fill.
Poprawka
Use type="email", type="tel" or type="url" and keep the matching autocomplete token. For digits that are not quantities (codes, card numbers) use type="text" with inputmode="numeric" (see html/no-number-for-codes).
Przykłady
<!-- bad -->
<input id="email" name="email">
<!-- good -->
<input id="email" name="email" type="email" autocomplete="email">Źródła
Fakty
- Identyfikator
html/input-type- Waga
- drobna
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
htmlangularvuesvelteastrojsx- Uczy jej skill
fe-formsNative forms and validation- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain html/input-type