Input Email maxLengthProperty

Input Email 对象参考手册Input Email Object

Example

Get the maximum number of characters allowed in the email field:

var x = document.getElementById("myEmail").maxLength;
xThe result is:
30

Try it Yourself »

Definition and Usage

The maxLength property is used to set or return the value of the maxlength attribute of the 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, and the number of characters, of the email field, please use thesizeattribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the maxLength property.

Note:Internet Explorer 9 (and earlier IE versions), or the Safari browser, do not support HTML <input> elements with type="email".


Syntax

Return the maxLength property:

emailObject.maxLength

Set the maxLength property:

emailObject.maxLength=number

Property Values

Value Description
number Describes the maximum number of characters allowed in the email field. The 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";

Try it Yourself »


Related Pages

HTML Reference:HTML <input> maxlength Attribute


Input Email 对象参考手册Input Email Object Other Extensions