If you want to limit the number of characters people can type in a textarea object. U should use a javascript because there is no such “maxlength” attribite as with a “normal” textbox.In the code below i use a small textbox (txtCounter) near the textarea to show the remaining characters.

Paste this code in the tag of your textarea

onkeydown=”EditCounter(frmYourForm,500)” onkeyup=”EditCounter(frmYourForm,500)”

this is the javascript function

function EditCounter(myform, MaxChar){
var elements = document.getElementsByTagName(‘textarea’);
if (elements[0].value.length >= MaxChar){
elements[0].value = String(elements[0].value).substring(0,MaxChar)
myform.txtCounter.value =MaxChar – elements[0].value.length ;
}else{
myform.txtCounter.value = MaxChar – elements[0].value.length ;
}
}

textcounter

Popularity: 3% [?]