Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

limiting characters in a text box

Status
Not open for further replies.

nkrst1

Programmer
Feb 13, 2001
49
US
Does anybody know how to limit the number of characters that can be TYPED (not READ) into a text box in HTML? For example, in this box i can type as much as I want, but all the text may not be READ. Can I get this cursor to stop accepting typed characters after the character limit has been reached?
 
<input type=text .... onchange=&quot;if (this.value.lenght>maxChars) this.value.lenght=maxChars&quot;>
or
<input type=text ... MAXLENGTH=&quot;maxChars&quot; SIZE=&quot;lengthChars&quot;>

where maxChars is an integer
all this is in basic reference docs (such as html tags reference) btw
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top