FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Limiting # characters in textarea
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
Limiting # characters in textarea [message #182528] Sat, 10 August 2013 16:54 Go to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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`
Re: Limiting # characters in textarea [message #182529 is a reply to message #182528] Sat, 10 August 2013 19:11 Go to previous messageGo to next message
Martin Leese is currently offline  Martin Leese
Messages: 23
Registered: June 2012
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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(at)see(dot)Web(dot)for(dot)e-mail(dot)INVALID
Web: http://members.tripod.com/martin_leese/
Re: Limiting # characters in textarea [message #182530 is a reply to message #182528] Sat, 10 August 2013 19:23 Go to previous messageGo to next message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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?-
Re: Limiting # characters in textarea [message #182531 is a reply to message #182529] Sat, 10 August 2013 19:23 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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`
Re: Limiting # characters in textarea [message #182532 is a reply to message #182528] Sat, 10 August 2013 19:36 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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(at)attglobal(dot)net
==================
Re: Limiting # characters in textarea [message #182533 is a reply to message #182528] Sat, 10 August 2013 20:52 Go to previous messageGo to next message
Richard Damon is currently offline  Richard Damon
Messages: 58
Registered: August 2011
Karma: 0
Member
add to buddy list
ignore all messages by this user
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.
Re: Limiting # characters in textarea [message #182534 is a reply to message #182531] Sat, 10 August 2013 21:57 Go to previous messageGo to next message
BootNic is currently offline  BootNic
Messages: 10
Registered: November 2010
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
In article <ku6i1b$rdl$1(at)speranza(dot)aioe(dot)org>, Twayne <nobody(at)spamcop(dot)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*
Re: Limiting # characters in textarea [message #182535 is a reply to message #182528] Sun, 11 August 2013 12:39 Go to previous messageGo to next message
Allodoxaphobia is currently offline  Allodoxaphobia
Messages: 21
Registered: September 2010
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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
Re: Limiting # characters in textarea [message #182542 is a reply to message #182530] Mon, 12 August 2013 13:43 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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`
Re: Limiting # characters in textarea [message #182543 is a reply to message #182533] Mon, 12 August 2013 13:48 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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`
Re: Limiting # characters in textarea [message #182544 is a reply to message #182542] Mon, 12 August 2013 18:13 Go to previous message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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?-
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: Re: Sexy CATHERINE ZETA JONES Sex Scandals
Next Topic: Email attachment 0bytes using php4
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Dec 17 05:11:44 EST 2017

Total time taken to generate the page: 0.00851 seconds