How to impose maxlength on text area in HTML?

Spread the love

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

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

How to impose maxlength on text area in HTML?

To impose maxlength on text area in HTML, we set the maxlength attribute.

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 add a text area into a form.

We set its maxlength attribute toi 100 to validate that its value is 100 characters or less.

Conclusion

To impose maxlength on text area in HTML, we set the maxlength attribute.

Leave a Reply

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