HTML | input maxlength Attribute
The <input> maxlength attribute is used to specify the maximum number of characters enters into the <input> element.
Syntax:
<input maxlength="number">
Attribute Value:
- number: It contains single value number which allows the maximum number of character in <input> element. Its default value is 524288.
Example:
<!DOCTYPE html> <html> <head> <title> HTML input maxlength Attribute </title> </head> <body> <center> <h1 style="color:green;"> GeeksforGeeks </h1> <h2> HTML <input> maxlength Attribute </h2> <form action="#"> Username: <input type="text" name="usrname" maxlength="12"> <br> <br> Password: <input type="text" name="password" maxlength="10"> <br> <br> <input type="submit" value="Submit"> </form> </center> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browsers supported by input maxlength Attribute are listed below:
- Google Chrome 1.0
- Internet Explorer 2.0
- Firefox 1.0
- Safari 1.0
- Opera 1.0
Recommended Posts:
- HTML maxlength Attribute
- HTML | DOM Input URL maxLength Property
- HTML | DOM Input Text maxLength Property
- HTML | DOM Input Email maxLength Property
- HTML | DOM Input Search maxLength Property
- HTML | DOM Input Password maxLength Property
- HTML | input value Attribute
- HTML | <input> alt Attribute
- HTML | <input> min Attribute
- HTML | <input> src Attribute
- HTML | <input>max Attribute
- HTML | <input> name Attribute
- HTML | <input> required Attribute
- HTML | <input> step Attribute
- HTML | <input> type Attribute
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.



