Locking Down Textbox

  • Thread starter Thread starter chuckdfoster
  • Start date Start date
C

chuckdfoster

Is there a way to limit the amount of characters a user can enter into a
textbox. I have a comment field that shouldn't have more than 50
characters. Currently, I check this length when the user clicks Submit, but
I have been asked to "lock the textbox down" so they can't enter more than
50 characters.
 
Actually, as soon as I got done posting that message I saw that, but cannot
seem to get it to work. I put the max length to 10 and it lets me type all
that I want. Is there anything else I need to change?

Thanks, Chuck Foster
 
what browser are you using, in IE the following HTML is produced

<input name="TextBox1" type="text" maxlength="3"/>

which only allows me to enter 3 characters
 
I think MaxLength is not support if you have a multiline textbox, which is
what you probably have if it is not working.

In this case, you need to trap the javascript events, so that on every
keypress, you check the character count and cancel the event if the maximum
has been reached.
 
That is my problem. I have a multi-line text box. Can you explain the
javascript even to me? an example maybe?

thanks, chuck foster
 

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

Back
Top