HTML | DOM Input Email maxLength Property
The Input Email maxLength property in HTML DOM is used to set or return the value of maxlength attribute of a Email Input Field. It specifies the maximum number of characters that have been allowed in the email field. The default value of Input Email maxLength property is 524288.
Syntax:
- It returns the Input Email maxLength property.
emailObject.maxLength
- It is used to set the Input Email maxLength property.
emailObject.maxLength = number
Property Values: It contains single value number which is used to specify the maximum number of characters that are allowed in the Email maxlength Field.
Return Value: It returns a numeric value which represents the maximum number of character that have been allowed in the Email maxlength field.
Example 1: This example illustrate how to return the Input Email maxLength property.
<!DOCTYPE html> <html> <head> <title> HTML DOM Input Email maxlength Property </title> </head> <body style="text-align:center;"> <h1> GeeksforGeeks</h1> <h2>DOM Input Email maxLength Property</h2> <form id="myGeeks"> E-mail: <input type="email" id="email" maxlength="45" value="manaschhabra22@gmail.com"> </form><br> <button onclick="myGeeks()"> Click Here! </button> <p id="GFG" style="font-size:25px;color:green;"></p> <!-- Script to access input element with type email attribute --> <script> function myGeeks() { var em = document.getElementById("email").maxLength; document.getElementById("GFG").innerHTML = em; } </script> </body> </html> |
Output:
Before clicking on the Button::

After clicking on the Button:

Example 2: This example illustrate how to set Input Email maxLength property.
<!DOCTYPE html> <html> <head> <title> HTML DOM Input Email maxlength Property </title> </head> <body style="text-align:center;"> <h1> GeeksforGeeks</h1> <h2>DOM Input Email maxLength Property</h2> <form id="myGeeks"> E-mail: <input type="email" id="email" maxlength="45" value="manaschhabra22@gmail.com"> </form><br> <button onclick="myGeeks()"> Click Here! </button> <p id="GFG" style="font-size:20px;color:green;"></p> <!-- Script to set Input Email maxlength Property --> <script> function myGeeks() { var em = document.getElementById("email").maxLength = "70"; document.getElementById("GFG").innerHTML = "The value of the maxlength attribute" + " was changed to :" + em; } </script> </body> </html> |
Output:
Before Clicking on Button:

After Clicking on Button:

Supported Browsers: The browser supported by DOM input Email maxLength property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM Input URL maxLength Property
- HTML | DOM Input Text maxLength Property
- HTML | DOM Input Password maxLength Property
- HTML | DOM Input Search maxLength Property
- HTML | DOM Input Email value Property
- HTML | DOM Input Email name Property
- HTML | DOM Input Email autocomplete Property
- HTML | DOM Input Email autofocus Property
- HTML | DOM Input Email size Property
- HTML | DOM Input Email type Property
- HTML | DOM Input Email required Property
- HTML | DOM Input Email multiple Property
- HTML | DOM Input Email Placeholder Property
- HTML | DOM Input Email readOnly Property
- HTML | DOM Input Email pattern Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



