[thelist] limit the size on entry on multiline text areas

spinhead evolt at spinhead.com
Thu Sep 6 16:07:38 CDT 2001


What about this?

function charsLimit(charsToCount, CountField, Limit) {
if (charsToCount.value.length > Limit)
charsToCount.value = charsToCount.value.substring(0, Limit);
else
CountField.value = Limit - charsToCount.value.length;

And in the textarea -
onKeyDown="charsLimit(this.form.Comments,this.form.chars_left,256);"
onKeyUp="charsLimit(this.form.Comments,this.form.chars_left,256);"

And finally, a little box to display how many characters you've got 'til it
explodes:
<input readonly type=text name=chars_left size=2 maxlength=3 value="256"
onClick="this.blur()">

(Don't remember why I have both keydown and keyup)

spinhead


----- Original Message -----
From: <Rory.Plaire at wahchang.com>
To: <thelist at lists.evolt.org>
Sent: Thursday, September 06, 2001 1:50 PM
Subject: RE: [thelist] limit the size on entry on multiline text areas


> | Does anyone know if
> | that script still exists, or how to modify this one?
>
>
> Scott,
>
> I think something like:
>
> document.form[num].textarea.value =
> document.form[num].textarea.value.substr(0,
> document.form[num].textarea.value.length-2);
>
> ...but this could be a one-off error.
>
> <rory disposition="merrily" alt="8)"/>
>
>
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt !
>





More information about the thelist mailing list