Attributo HTML <input> maxlength

❮ Tag HTML <input>

Esempio

Un elemento <input> con una lunghezza massima di 10 caratteri:

<form action="/action_page.php">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username" maxlength="10"><br><br>
  <input type="submit" value="Submit">
</form>

Definizione e utilizzo

L' maxlengthattributo specifica il numero massimo di caratteri consentiti <input>nell'elemento.


Supporto browser

I numeri nella tabella specificano la prima versione del browser che supporta completamente l'attributo.

Attribute
maxlength Yes Yes Yes Yes Yes

Sintassi

<input maxlength="number">

Valori di attributo

Value Description
number The maximum number of characters allowed in the <input> element. Default value is 524288

❮ Tag HTML <input>