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


Groups > comp.lang.php > #10481 > unrolled thread

Limiting # characters in textarea

Started byTwayne <nobody@spamcop.net>
First post2013-08-10 16:54 -0400
Last post2013-08-11 16:39 +0000
Articles 11 — 7 participants

Back to article view | Back to comp.lang.php


Contents

  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

#10481 — Limiting # characters in textarea

FromTwayne <nobody@spamcop.net>
Date2013-08-10 16:54 -0400
SubjectLimiting # characters in textarea
Message-ID<ku699n$77d$1@speranza.aioe.org>
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`

[toc] | [next] | [standalone]


#10482

FromMartin Leese <please@see.Web.for.e-mail.INVALID>
Date2013-08-10 17:11 -0600
Message-ID<ku6hbm$t27$1@dont-email.me>
In reply to#10481
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.
...
> I discovered maxlength has been added to HTML 5 but many people aren't 
> using HTML 5 compatibility yet.

Yes, but are they using maxlength?
Maxlength has been allowed in <input> tags
since HTML 4 (1999), so my guess that all
modern browsers also use it with <textarea>.
However, this is only a guess.

-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/

[toc] | [prev] | [next] | [standalone]


#10484

FromTwayne <nobody@spamcop.net>
Date2013-08-10 19:23 -0400
Message-ID<ku6i1b$rdl$1@speranza.aioe.org>
In reply to#10482
On 2013-08-10 7:11 PM, Martin Leese wrote:
> 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.
> ...
>> I discovered maxlength has been added to HTML 5 but many people aren't
>> using HTML 5 compatibility yet.
>
> Yes, but are they using maxlength?
> Maxlength has been allowed in <input> tags
> since HTML 4 (1999), so my guess that all
> modern browsers also use it with <textarea>.
> However, this is only a guess.
>

Unfortunately, no, maxlength does not work on textarea. It was added to 
HTML 5 but not all browsers will honor it, Opera in particular. Thus my 
quest for a way to mimic it.

Twayne`

[toc] | [prev] | [next] | [standalone]


#10487

FromBootNic <bootnic.bounce@gmail.com>
Date2013-08-10 21:57 -0400
Message-ID<20130810215745.180fdd44@bootnic.server>
In reply to#10484

[Multipart message — attachments visible in raw view] — view raw

In article <ku6i1b$rdl$1@speranza.aioe.org>, Twayne <nobody@spamcop.net>
wrote:

[snip]

> Unfortunately, no, maxlength does not work on textarea. It was added
> to HTML 5 but not all browsers will honor it, Opera in particular. Thus
> my quest for a way to mimic it.

For Opera one could add an invalid pattern attribute. Opera will still not
truncate the input, but it will prevent the form from submitting.

<textarea name=text pattern="^[\w\W]{0,50}$" maxlength=50></textarea>

Followup-To:alt.html


-- 
BootNic                                               Sat Aug 10, 2013 09:57 pm
  Inform all the troops that communications have completely broken down.
  *Ashleigh Brilliant*

[toc] | [prev] | [next] | [standalone]


#10483

FromNorman Peelman <npeelman@cfl.rr.com>
Date2013-08-10 19:23 -0400
Message-ID<ku6i13$vv5$1@dont-email.me>
In reply to#10481
On 08/10/2013 04: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`

   maxlength has been around long before HTML5... The <input> control 
will simply stop accepting characters. Without JS, it will just truncate 
upon insertion, even from copy/paste. You'll just have to indicate that 
data entry for that field is limited.

-- 
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-

[toc] | [prev] | [next] | [standalone]


#10495

FromTwayne <nobody@spamcop.net>
Date2013-08-12 13:43 -0400
Message-ID<kub6r8$9ui$1@speranza.aioe.org>
In reply to#10483
On 2013-08-10 7:23 PM, Norman Peelman wrote:
> On 08/10/2013 04:54 PM, Twayne wrote:
>> Hi all,
>>
>> Win 7, XAMPP Local Server, PHP 5.3. Target; Online Submitted Forms for
>> the general public:

>> 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`
>
>    maxlength has been around long before HTML5... The <input> control
> will simply stop accepting characters. Without JS, it will just truncate
> upon insertion, even from copy/paste. You'll just have to indicate that
> data entry for that field is limited.
>

Not quite unfortunately. What you say is true, with the exception of 
using a <textarea>. Maxlength simply will not work with a textarea (Not 
talking about "input" etc. here) and never has until it was added for 
HTML 5.
    Try it; create a textarea with a length of say 10 and use maxlength; 
it will not work unless you're able to handle the latest HTML 5 code.
Regards,

Twayne`

[toc] | [prev] | [next] | [standalone]


#10497

FromNorman Peelman <npeelman@cfl.rr.com>
Date2013-08-12 18:13 -0400
Message-ID<kubmms$k8g$1@dont-email.me>
In reply to#10495
On 08/12/2013 01:43 PM, Twayne wrote:
> On 2013-08-10 7:23 PM, Norman Peelman wrote:
>> On 08/10/2013 04:54 PM, Twayne wrote:
>>> Hi all,
>>>
>>> Win 7, XAMPP Local Server, PHP 5.3. Target; Online Submitted Forms for
>>> the general public:
>
>>> 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`
>>
>>    maxlength has been around long before HTML5... The <input> control
>> will simply stop accepting characters. Without JS, it will just truncate
>> upon insertion, even from copy/paste. You'll just have to indicate that
>> data entry for that field is limited.
>>
>
> Not quite unfortunately. What you say is true, with the exception of
> using a <textarea>. Maxlength simply will not work with a textarea (Not
> talking about "input" etc. here) and never has until it was added for
> HTML 5.
>     Try it; create a textarea with a length of say 10 and use maxlength;
> it will not work unless you're able to handle the latest HTML 5 code.
> Regards,
>
> Twayne`
>

   Yes, I noticed the disclaimer a little too late... works in Google 
Chrome and Firefox but not Opera and IE 9 and earlier. Tested except for IE.

-- 
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-

[toc] | [prev] | [next] | [standalone]


#10485

FromJerry Stuckle <jstucklex@attglobal.net>
Date2013-08-10 19:36 -0400
Message-ID<ku6iqd$2ti$1@dont-email.me>
In reply to#10481
On 8/10/2013 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`

How do the hell do you expect something server-side to prevent the 
client from sending something?

Oh, I forgot.  You're an illiterate troll - who doesn't care about the 
right answer.  Just one that agrees with your incorrect perceptions.



-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#10486

FromRichard Damon <Richard@Damon-Family.org>
Date2013-08-10 20:52 -0400
Message-ID<3fBNt.680$nK2.185@en-nntp-11.dc1.easynews.com>
In reply to#10481
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.

[toc] | [prev] | [next] | [standalone]


#10496

FromTwayne <nobody@spamcop.net>
Date2013-08-12 13:48 -0400
Message-ID<kub74l$9ui$2@speranza.aioe.org>
In reply to#10486
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`

[toc] | [prev] | [next] | [standalone]


#10488

FromAllodoxaphobia <knock_yourself_out@example.net>
Date2013-08-11 16:39 +0000
Message-ID<slrnl0ffig.120a.knock_yourself_out@vps.jonz.net>
In reply to#10481
On Sat, 10 Aug 2013 16:54:13 -0400, 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. 

Why do you think The Bad Guys will be pulling _your_ copy of the 
HTML to try to push cracking attempts at you?

	http://en.wikipedia.org/wiki/CURL

Jonesy

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web