Re: Limiting text inputs by character count?
| From: | George Whiffen | Date: | Mon, 24 Jun 2002 14:18:20 +0000 |
| Subject: | Re: Limiting text inputs by character count? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-103587@lists.php.net to get a copy of this message | ||
John Holmes wrote:
> The best way to do this is server side with strlen(). You can use
> javascript or maxlength, but if a user wants to get around it, they can.
>
> ---John Holmes...
>
John,
The best way to do this is with both. maxlength/Javascript as a courtesy,
strlen for security.
As you say, you can NEVER rely on any kind of client-side check, all checks
must be done on the server side. So, it's tempting to skip client-side checks,
but making the user wait for server side execution before any checks are done
is actually very rude. Every time I see server-only checks for required fields etc.,
I switch off and lose confidence in the site.
George
>
> > -----Original Message-----
> > From: Martin Towell [mailto:martin.towell@world.net]
> > Sent: Sunday, June 23, 2002 9:47 PM
> > To: 'aajdubuc@webhart.net'; php-general@lists.php.net
> > Subject: RE: [PHP] Limiting text inputs by character count?
> >
> > a) maxlength="xx"
> > b) use javascript
> > (document.forms["frm_name"].elements["textarea"].value.length)
> > (I think you need the ".value" bit)
> >
> >
> > -----Original Message-----
> > From: Andre Dubuc [mailto:aajdubuc@webhart.net]
> > Sent: Monday, June 24, 2002 11:53 AM
> > To: php-general@lists.php.net
> > Subject: [PHP] Limiting text inputs by character count?
> >
> >
> > Is there a way to limit the number of characters that may be inputed
> into:
> > a) a <input type=text . . . > input
> > b) a <textarea . . . > input
> >
> > I would like to control the maximum number of characters for each of
> these
> > inputs.
> >
> > Any suggestions of where to look, or how to do it, if it's possible,
> would
> > be
> > greatly appreciated.
> >
> > Tia,
> > Andre
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php