Input Email maxLength Property
Example
Get the maximum number of characters allowed in the email field:
var x = document.getElementById("myEmail").maxLength;
30
Definition and Usage
The maxLength property is used to set or return the value of the maxlength attribute of an email field.
The maxLength property describes the maximum number of characters allowed in the email field.
The default value is 524288.
Tip: To set or return the length of the email field, in characters, use the size property.
Browser Support
All major browsers support the maxLength property.
Note: Internet Explorer 9 (and earlier versions) or Safari do not support the HTML <input> element with type="email".
Syntax
Return the maxLength property:
Set the maxLength property:
Property Values
| Value | Description |
|---|---|
| number | Describes the maximum number of characters allowed in the email field. Default value is 524288 |
Technical Details
| Return Value: | A number, representing the maximum number of characters allowed in the email field. | | --- | --- |
More Examples
Example
Set the maximum number of characters allowed in the email field:
document.getElementById("myEmail").maxLength = "8";
Related Pages
HTML Reference: HTML <input> maxlength Attribute