HTML DOM Textarea maxLength प्रॉपर्टी किसी HTML दस्तावेज़ में टेक्स्ट एरिया एलिमेंट के maxLength एट्रिब्यूट के मान को लौटाती है और संशोधित करती है।
सिंटैक्स
निम्नलिखित वाक्य रचना है -
<मजबूत>1. लौटने की अधिकतम लंबाई
object.maxLength
<मजबूत>2. अधिकतम लम्बाई संशोधित करना
object.maxLength = “number”
आइए HTML DOM Textarea maxLength प्रॉपर्टी का एक उदाहरण देखें:
उदाहरण
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 40%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
}
.show {
font-size: 1.5rem;
margin: 1rem 0;
}
</style>
<body>
<h1>DOM Textarea maxLength Property Demo</h1>
<textarea maxlength="50">Hi! I'm a text area element with some dummy text.</textarea>
<button onclick="set()" class="btn">Show Maximum Length</button>
<div class="show"></div>
<script>
function set() {
document.querySelector('.show').innerHTML = 'The maximum number of characters allowed in the above text area is ' + document.querySelector("textarea").maxLength;
}
</script>
</body>
</html> आउटपुट

"अधिकतम लंबाई दिखाएं . पर क्लिक करें textarea तत्व की maxLength विशेषता का मान प्रदर्शित करने के लिए बटन।
