Setting character limit for a multi line text area

message from adenucci36 on 21 Jul 2004
I have a form with some text areas. When the form is submitted, the info in
these areas is written to a database. The database has a max. limit of
characters it will accept for specific fields. Therefore, I need to make the
limit on these areas the same. I know how to do a character limit on a single
line text box, but we want our users to be able to see more than one line of
text when they are typing. I have a text area set up. I know there are
options for Char Width and Num Lines, but to my understanding these control the
amount of text displayed, not how much text can be entered. Is there any way
to limit the amount of text entered in a text area?
 
cmbergin replied to adenucci36 on 21 Jul 2004
You can't really limit the number of characters that are entered. You could
implement a javascript function that checks the lengthl of the textarea onBlur.
Then you can tell the user that it's too long and return focus to the
textarea, effectively "trapping" the user until the text is within your limit.

Alternatively (or, more likely, additionally) you can check the length
server-side before attempting the database insertion, then return the user to
the form with an appropriate message if the textarea's data won't fit in the
database field.
 

Archived message: Setting character limit for a multi line text area (Macromedia Dreamweaver)