Entry
How can I take the control over the length of a TEXTAREA tag? (as the "maxlength" atribute of the INPUT tag)
Aug 25th, 2000 16:13
Ben Udall, John Marc, Diego Arnaiz, http://www.w3.org/TR/html4/interact/forms.html#h-17.7
While HTML does not have an equivilent, the following Javascript
routine will simulate the character limiting features of MAXLENGTH
Just replace the "500" with whatever value you need
<SCRIPT LANGUAGE="JavaScript">
<!-- hide
function maxlength(max){
if (document.form.desc.value.length >= max) {
document.form.desc.value = document.form.desc.value.substring
(0,max);
alert (max+" MAX exceeded!");
return false;
}
}
-->
</script>
<form name="form">
<textarea name="desc" COLS="60" rows="$langnum" onkeypress="maxlength
(500)">Not too big, now....</textarea>
</form>
John Marc