Input Email maxLength Attribute
Definition and Usage
maxLength
Sets or returns the value of the maxlength attribute of the email field.
The HTML maxLength attribute specifies the maximum number of characters allowed in the email field.
The default value is 524288.
Tip:To set or return the width of the email field (in characters), use size attribute.
See also:
HTML Reference Manual:HTML <input> maxlength Attribute
Example
Example 1
Get the maximum number of characters allowed in a specific email field:
var x = document.getElementById("myEmail").maxLength;
Example 2
Set the maximum number of characters allowed in the email field:
document.getElementById("myEmail").maxLength = "8";
Syntax
Return the maxLength attribute:
emailObject.maxLength
Set the maxLength attribute:
emailObject.maxLength = number
Attribute value
Value | Description |
---|---|
number | Specifies the maximum number of characters allowed in the email field. The default value is 524288. |
Technical Details
Return Value: | Number, 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 attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |