Re: Blocking input into a text area
- From: RobG <rgqld@xxxxxxxxxxxx>
- Date: Sun, 29 Apr 2007 15:00:55 +1000
eggie5@xxxxxxxxx wrote:
I wrote a script that tracks the number of characters a user types
into a text box. It has a limit you can set, and when that limit is
reached I would like to block the user from entering any more text.
How can I block the user from typing characters in the text area?
There is no reliable way prevent the entry of characters using script. There are some scripts which, once the limit has been reached, try to detect on keydown if a character within a certain range has been pressed and cancel it. However you have to allow users use of cursor keys, delete, backspace, etc.
In any case, that method doesn't stop users entering as much text as they like by pasting.
Your best bet is to validate the content when the form is submitted and tell the user that they've put too many characters in the text area. You might also have a keyup handler that shows the users how many characters they have left.
Make sure your server can handle getting any number of characters from the text area.
--
Rob
.
- References:
- Blocking input into a text area
- From: eggie5@xxxxxxxxx
- Blocking input into a text area
- Prev by Date: Re: Help with "cannot assign string" error
- Next by Date: Re: Imagine life without Javascript...
- Previous by thread: Blocking input into a text area
- Next by thread: Re: Blocking input into a text area
- Index(es):
Relevant Pages
|