Textarea maxLength Property - Change the maximum number of characters allowed in a text area: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Description

Textarea maxLength Property - Change the maximum number of characters allowed in a text area:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Address:<br>
<textarea id="myTextarea">
</textarea>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from   w  ww. ja v  a2  s  .  c  o m*/
    document.getElementById("myTextarea").maxLength = "4";
    document.getElementById("demo").innerHTML = "Maximum number of characters allowed in the text area is now 4.";
}
</script>

</body>
</html>

Related Tutorials