Re: Can you add maxlength to a TEXTAREA field in a form "Serg" wrote ...
>I mean let's face it, using just text you can, but it's an ugly one
> line field.
>
> And in textarea, it's all pretty, but there doesn't seem to be way to
> limit the length.
>
> What gives? And how could someone not design an inbetween?
For that Serg you would be requiring a little client side script - add a
javascript function that counts the characters that have been entered,
triggered by a text change or a keypress - when it getes to the magical
figure, prevent the user from entering anymore text and maybe display an
alert box to the screen to advise them...
Something like this could be good:
Put this in the HEAD tags of your page...
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
alert("parp!");
}
// End -->
</script>
Put within your FORM tags..
<textarea name="message" onKeyDown="textCounter(this.form.message,125);"
onKeyUp="textCounter(this.form.message,125);"></textarea>
Give it a go - hope it helps..
Rob |