Latest web development tutorials
 

Input Email maxLength Property

< Input Email Object

Example

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

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

The result of x will be:

30
Try it Yourself »

Definition and Usage

The maxLength property sets or returns the value of the maxlength attribute of an email field.

The 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 an email field, in number of characters, use the size property.


Browser Support

Property
maxLength Yes 10.0 Yes Yes Yes

Syntax

Return the maxLength property:

emailObject.maxLength

Set the maxLength property:

emailObject.maxLength=number

Property Values

Value Description
number Specifies 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 an email field:

document.getElementById("myEmail").maxLength = "8";
Try it Yourself »

Related Pages

HTML reference: HTML <input> maxlength attribute


< Input Email Object