Blocking input into a text area

E

eggie5

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?
 
R

RobG

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.
 
S

shimmyshack

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?

all been dealt with in this ng under the title Textarea on april 26
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top