Categories
HTML

How to impose maxlength on text area in HTML?

Spread the love

Sometimes, we want to impose maxlength on text area in HTML using JavaScript.

In this article, we’ll look at how to impose maxlength on text area in HTML using JavaScript.

How to impose maxlength on text area in HTML?

To impose maxlength on text area in HTML using JavaScript, we can set the maxlength attribute of the input.

For instance, we write

<!DOCTYPE html>
<html>
  <body>
    <form action="processForm.php" action="post">
      <label for="story">Tell me your story:</label><br />
      <textarea id="story" maxlength="100"></textarea>
      <input type="submit" value="Submit" />
    </form>
  </body>
</html>

to set the maxlength attribute of the textarea element to 100 characters.

Conclusion

To impose maxlength on text area in HTML using JavaScript, we can set the maxlength attribute of the input.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *