
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Textarea maxLength Property
The HTML DOM Textarea maxLength property returns and modify the value of maxLength attribute of a text area element in an HTML document.
Syntax
Following is the syntax −
1. Returning maxLength
object.maxLength
2. Modifying maxLength
object.maxLength = “number”
Let us see an example of HTML DOM Textarea maxLength Property:
Example
<!DOCTYPE html> <html> <style> body { color: #000; height: 100vh; } .btn { background: #db133a; border: none; height: 2rem; border-radius: 2px; width: 40%; display: block; color: #fff; outline: none; cursor: pointer; } .show { font-size: 1.5rem; margin: 1rem 0; } </style> <body> <h1>DOM Textarea maxLength Property Demo</h1> <textarea maxlength="50">Hi! I'm a text area element with some dummy text.</textarea> <button onclick="set()" class="btn">Show Maximum Length</button> <div class="show"></div> <script> function set() { document.querySelector('.show').innerHTML = 'The maximum number of characters allowed in the above text area is ' + document.querySelector("textarea").maxLength; } </script> </body> </html>
Output
Click on “Show Maximum Length” button to display the value of maxLength attribute of the textarea element.
- Related Articles
- HTML DOM Input URL maxLength Property
- HTML DOM Input Password maxLength Property
- HTML DOM Input Search maxLength Property
- HTML DOM Input Text maxLength Property
- HTML DOM Input Email maxLength Property
- HTML DOM Textarea cols Property
- HTML DOM Textarea rows Property
- HTML DOM Textarea placeholder Property
- HTML DOM Textarea disabled Property
- HTML DOM Textarea defaultValue Property
- HTML DOM Textarea name Property
- HTML DOM Textarea readOnly Property
- HTML DOM Textarea wrap Property
- HTML DOM Textarea autofocus Property
- HTML DOM Textarea form Property

Advertisements