Im using Html.TextArea in my application and when i set its maxlength property to 255. It doesnt work and write more than 255 characters. how can this problem be solved
+2
A:
Take a look at this: http://stackoverflow.com/questions/1125482/how-to-impose-maxlength-on-textarea-in-html-javascript
Ju9OR
2010-06-24 12:11:27
+1
A:
The HTML <textarea>
tag does not support the "maxlength" property. A variety of Javascript solutions exist, some for frameworks and others stand-alone. Basically it's necessary to catch keypress events (with Javascript) and track the content length. Usually some messaging to users is considered a Really Good Idea, like the Stackoverflow "Comment" boxes have.
Pointy
2010-06-24 12:12:25
A:
You can use a JavaScript validator. For example,
function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length > limitNum) {
limitField.value = limitField.value.substring(0, limitNum);
} else {
limitCount.value = limitNum - limitField.value.length;
}
}
<textarea name="limitedtextarea" onKeyDown="limitText(this.form.limitedtextarea,this.form.countdown,255);"
SageNS
2010-06-24 12:13:51