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.
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 ;
}
}

| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Nov | ||||||
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 | |
RSS feed for comments on this post · TrackBack URI
Leave a reply