Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Email maxLength property

Input Email maxLength property

Input Email Object Reference Input Email Object

Example

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

var x = document.getElementById("myEmail").maxLength;

x

The output is:

30

Try it »


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 of the email field, i.e. the number of characters, use size attribute.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the maxLength property.

Note: Internet Explorer 9 (and earlier IE versions) or Safari browser does not support the HTML element with type="email". .


Syntax

Return the maxLength property:

emailObject

.maxLength

Set the maxLength property:

emailObject

.maxLength=

number

Attribute values

Value Description
number Describes the maximum number of characters allowed in the email field. The default value is 524288

Technical Details

Return Value: 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 »


Related pages

HTML Reference Manual: HTML maxlength property


Input Email Object Reference Input Email Object