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.