setting the maximum for a memo box?

liunx

Guest
hello<br />
<br />
im using a multiline text field for my form and i was wondering if it is possible to set a maximum length like you do with the simple text fields?<br />
<br />
<br />
thanx in advance<br />
alex<!--content-->hmm so tell me how you limit characters in a simple text field<!--content-->if you mean limit the characters inside of a textarea, you'll need to use a bit of code to help out. I use the following:<br />
<br />
<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br />
<html><br />
<head><br />
<title>Untitled</title><br />
<SCRIPT LANGUAGE="JavaScript"><br />
<!-- Original: Ronnie T. Moore --><br />
<!-- Web Site: The JavaScript Source --><br />
<br />
<!-- Dynamic 'fix' by: Nannette Thacker --><br />
<!-- Web Site: <!-- m --><a class="postlink" href="http://www.shiningstar.net">http://www.shiningstar.net</a><!-- m --> --><br />
<br />
<!-- This script and many more are available free online at --><br />
<!-- The JavaScript Source!! <!-- m --><a class="postlink" href="http://javascript.internet.com">http://javascript.internet.com</a><!-- m --> --><br />
<br />
<!-- Begin<br />
function textCounter(field, countfield, maxlimit) {<br />
if (field.value.length > maxlimit) // if too long...trim it!<br />
field.value = field.value.substring(0, maxlimit);<br />
// otherwise, update 'characters left' counter<br />
else <br />
countfield.value = maxlimit - field.value.length;<br />
}<br />
// End --><br />
</script><br />
</head><br />
<body><br />
<form name=form1><br />
<textarea name=content cols=70 rows=18 onKeyDown="textCounter(this.form.content,this.form.remLen,4000);" <br />
onKeyUp="textCounter(this.form.content,this.form.remLen,4000);" <br />
onFocus="textCounter(this.form.content,this.form.remLen,4000);"><br />
</textarea><br />
<br><br><br />
<input readonly type=text name=remLen size=2 maxlength=3 value="4000" style="border: 1px;"> characters left</font><br />
</form><br />
</body><br />
</html><!--content-->
 
Back
Top