[thelist] textarea limitations

Michael Pemberton mpember at phreaker.net
Mon Oct 1 00:21:12 CDT 2001


I've done some stuff similar to this, here's what I've got.

The following function extends the JS string object and add the wordCount()
method:
    String.prototype.wordCount=function() { return this.split(" ").length; };
Here's a standalone version if that is more to your liking:
    wordCount=function(value) { return value.split(" ").length; };

To use this method to count lines, it should juse be the following changes:
    String.prototype.wordCount=function() { return this.split("\n").length; };
    wordCount=function(value) { return value.split("\n").length; };

Adrian Fischer wrote:

> Ahh...you've caught me out.  I know very little about how to do that.  The
> maxlength thing I've sussed out and works fine.  Stops them from inputting
> more than xx characters.  But if within that xx characters they hit enter a
> dozen times it throws my formatting out.  I want to limit them to just 6
> lines of text, regardless of how many of the xx characters they have used. I
> guess that needs to include line wraps for those that just keep typing and
> don't put in new lines.
>
> Not an easy task for a JS quamby.
>
> Some hints or redirection wouldn't go astray.
>
> Adrian Fischer
> AussieBidder
>
> > Why not do that client side? Before the form submits, use the regular
> > expression object to weed out multiple newlines before they ever make
> > it to the server.
> >
> > -bill
>
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt !

--
Michael Pemberton
mpember at phreaker.net
ICQ: 12107010








More information about the thelist mailing list