Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #10496

Re: Limiting # characters in textarea

From Twayne <nobody@spamcop.net>
Newsgroups comp.lang.php
Subject Re: Limiting # characters in textarea
Date 2013-08-12 13:48 -0400
Organization Aioe.org NNTP Server
Message-ID <kub74l$9ui$2@speranza.aioe.org> (permalink)
References <ku699n$77d$1@speranza.aioe.org> <3fBNt.680$nK2.185@en-nntp-11.dc1.easynews.com>

Show all headers | View raw


On 2013-08-10 8:52 PM, Richard Damon wrote:
> On 8/10/13 4:54 PM, Twayne wrote:
>> Hi all,
>>
>> Win 7, XAMPP Local Server, PHP 5.3. Target; Online Submitted Forms for
>> the general public:
>>
>> I am trying to come up with a way to force a limit to the length of a
>> textarea. It would be nice, but it's not a dealbreaker if it's not
>> reasonable to do due to imposed limitations,  if a counter could display
>> characters entered or characters left. Or even just stopping accepting
>> digits when the limit is reached would also be acceptable. I'm pretty
>> flexible; exact counts aren't even necessary if they're just ballpark
>> numbers.
>>
>> I discovered maxlength has been added to HTML 5 but many people aren't
>> using HTML 5 compatibility yet.
>>     I've located several ways to make it happen that use javascript or
>> JQuery, but javascript isn't allowed to be used in this case. I've done
>> a fair amount of research without any real success, I'm afraid.
>>
>> The limitation I want to impose is in addition the the "standard" ways
>> of validating the textarea. I don't want to be victimized by a
>> "character  bomb" or something similar that goes on for pages and pages,
>> for instance.
>> Using only HTML or PHP or a combo of the two, might anyone here have a
>> proven method for limiting the length of a textarea other than
>> truncating it without the sender's knowledge?
>>
>> Except for js and the like, I'm open to alternatives, of course.
>> Although code is always nice, air code often suffices too.
>>
>> Thanks in advance,
>>
>> Twayne`
>
> No matter what you place in your form to limit the field, you script
> still needs to be robust against an over-length field, as the submission
> is user controlled, and may possible contain any data the user wishes to
> send. (Validate ALL user input).
>
> You can always get around the "without the sender's knowledge" by having
> the validation send the user a message (on the resultant page), and
> possible ask for confirmation.
>

That's a good point and I agree since I've already shown the message 
content to the user on the page with the Submit button. I'm thinking I 
may need to go to js but I'm looking at some PHP solutions that might be 
possible; no idea yet, really.

Thanks,

Twayne`

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Limiting # characters in textarea Twayne <nobody@spamcop.net> - 2013-08-10 16:54 -0400
  Re: Limiting # characters in textarea Martin Leese <please@see.Web.for.e-mail.INVALID> - 2013-08-10 17:11 -0600
    Re: Limiting # characters in textarea Twayne <nobody@spamcop.net> - 2013-08-10 19:23 -0400
      Re: Limiting # characters in textarea BootNic <bootnic.bounce@gmail.com> - 2013-08-10 21:57 -0400
  Re: Limiting # characters in textarea Norman Peelman <npeelman@cfl.rr.com> - 2013-08-10 19:23 -0400
    Re: Limiting # characters in textarea Twayne <nobody@spamcop.net> - 2013-08-12 13:43 -0400
      Re: Limiting # characters in textarea Norman Peelman <npeelman@cfl.rr.com> - 2013-08-12 18:13 -0400
  Re: Limiting # characters in textarea Jerry Stuckle <jstucklex@attglobal.net> - 2013-08-10 19:36 -0400
  Re: Limiting # characters in textarea Richard Damon <Richard@Damon-Family.org> - 2013-08-10 20:52 -0400
    Re: Limiting # characters in textarea Twayne <nobody@spamcop.net> - 2013-08-12 13:48 -0400
  Re: Limiting # characters in textarea Allodoxaphobia <knock_yourself_out@example.net> - 2013-08-11 16:39 +0000

csiph-web