How to set Max Length in Textarea

You can use maxlength attribute inside your textarea’s opening tag.

The maxlength attribute helps you specify the maximum number of characters inside the specific element.

Important note: Keep in mind that it’s quite easy for potential hackers to remove this tag in their DevTools. That being said, if you want to store or do something important with that data, always validate it in your backend.

<textarea maxlength="3"></textarea>

Example:

<label for="myTextarea"><b>Message (max 30 characters):</b></label><hr>
<textarea maxlength="30" name="myTextarea" style="width: 50%; height: 200px"></textarea>

Output: