1
How do I stop the user from entering more than x number of chars in a textarea
2
==============================================================================
3
Internet Explorer 4 and Netscape Navigator 4 can capture keystrokes but have
4
problems if the user presses backspace or so...
6
I would try this - the onKeyUp counts the strokes in v4 and the onChange
7
does the dirty deed on v3:
9
<script language="JavaScript"><!--
14
function change(what) {
15
if (!alerted) alert('Keep it short, please');
16
what.value = what.value.substring(0,maxKeys-1); // chop after 100
20
function keyup(what) {
22
if (keysSoFar > maxKeys) {
23
if (!alerted) alert('That\'s enough!');
24
what.value = what.value.substring(0,maxKeys-1); // chop the last
32
<textarea cols=100 rows=20 onChange="change(this)"
33
onKeyUp="keyup(this)"></textarea>