Inserisci la proprietà maxLength dell'URL
Esempio
Ottieni il numero massimo di caratteri consentiti in un campo URL specifico:
var x = document.getElementById("myURL").maxLength;
Definizione e utilizzo
La proprietà maxLength imposta o restituisce il valore dell'attributo maxlength di un campo URL.
L'attributo maxLength specifica il numero massimo di caratteri consentiti nel campo URL.
Il valore predefinito è 524288.
Suggerimento: per impostare o restituire la larghezza di un campo URL, in numero di caratteri, utilizzare la proprietà size .
Supporto del browser
Property | |||||
---|---|---|---|---|---|
maxLength | Yes | 10.0 | Yes | Not supported | Yes |
Sintassi
Restituisce la proprietà maxLength:
urlObject.maxLength
Imposta la proprietà maxLength:
urlObject.maxLength = number
Valori di proprietà
Value | Description |
---|---|
number | Specifies the maximum number of characters allowed in the URL field. Default value is 524288 |
Dettagli tecnici
Valore di ritorno: | Un numero, che rappresenta il numero massimo di caratteri consentiti nel campo URL |
---|
Altri esempi
Esempio
Imposta il numero massimo di caratteri consentiti in un campo URL:
document.getElementById("myURL").maxLength = "8";
Pagine correlate
Riferimento HTML: Attributo HTML <input> maxlength
❮ Inserisci l'oggetto URL