Input Email maxLength 属性
定义和用法
maxLength
属性设置或返回电子邮件字段的 maxlength 属性的值。
HTML maxLength 属性规定电子邮件字段中允许的最大字符数。
默认值为 524288。
提示:如需设置或返回电子邮件字段的宽度(以字符数表示),请使用 size 属性。
另请参阅:
HTML 参考手册:HTML <input> maxlength property
实例
例子 1
获取特定电子邮件字段中允许的最大字符数:
var x = document.getElementById("myEmail").maxLength;
例子 2
设置电子邮件字段中允许的最大字符数:
document.getElementById("myEmail").maxLength = "8";
语法
返回 maxLength 属性:
emailObject.maxLength
设置 maxLength 属性:
emailObject.maxLength = number
属性值
Value | Description |
---|---|
number | Specifies the maximum number of characters allowed in the email field. The default value is 524288. |
Technical details
Return value: | Value, indicating the maximum number of characters allowed in the email field. |
---|
Browser support
The numbers in the table indicate the first browser version that fully supports this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |