textarea – maxlength equivalent – easy way of limiting the max number of characters
The easiest way to limit the maximum length someone can type into a textarea field of your form is to do the following:
<textarea name=”mytextarea” id=”mytextarea” cols=”50″ rows=”4″ onkeypress=”return (this.value.length < 20);” >
Where 20 is the maximum number of characters you want to show. This seems to work well on Chrome and IE. I found a lot of other examples on the web that require 30 lines of code, but this is the simplest way, just using the onkeypress event.
onkeypress=”return (this.value.length < 20);”