Input Email maxLength 属性
定义和用法
maxLength
属性设置或返回电子邮件字段的 maxlength 属性的值。
HTML maxLength 属性规定电子邮件字段中允许的最大字符数。
默认值为 524288。
提示:如需设置或返回电子邮件字段的宽度(以字符数表示),请使用 size 属性。
另请参阅:
HTML 参考手册:Proprietà maxlength dell'<input> HTML
实例
例子 1
获取特定电子邮件字段中允许的最大字符数:
var x = document.getElementById("myEmail").maxLength;
例子 2
设置电子邮件字段中允许的最大字符数:
document.getElementById("myEmail").maxLength = "8";
语法
返回 maxLength 属性:
emailObject.maxLength
设置 maxLength 属性:
emailObject.maxLength = number
属性值
Valore | Descrizione |
---|---|
number | Specificare il numero massimo di caratteri permessi nel campo email. Il valore predefinito è 524288. |
Dettagli tecnici
Valore di ritorno: | Valore numerico che rappresenta il numero massimo di caratteri permessi nel campo email. |
---|
Supporto del browser
I numeri nella tabella indicano la versione del browser che supporta completamente l'attributo.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Supporto | 10.0 | Supporto | Supporto | Supporto |