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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit Number of Characters In Rich Text Box

R5 - Web Applications

Limit Number of Characters In Rich Text Box

by  NiteLink  Posted    (Edited  )
JS Header (Haven't tried onChange):

Code:
function textCounter(field, countfield, maxlimit) {
var Comments = document.forms[0].Comments;

if (Comments.value.length > maxlimit) 
Comments.value = field.value.substring(0, maxlimit);
else 
countfield.value = maxlimit - Comments.value.length;
}

onKeyDown & onKeyUp:

Code:
textCounter(this.form.Comments, this.form.remLen, maxlimit)

Pass Text Thru HTML:

Code:
<input readonly="readonly" type="text" name="remLen" size="3" maxlength="3" value="maxlimit"> characters left.<br>

NB: Replace maxlimit with the number of characters that you want users to type.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top