Limit Textarea 2 | JavaScriptSource

Limit Textarea 2

Ilya Gerasimenko Jan 9, 2008


This script limits text input to 20 characters per line for a total of 10 lines. Numbers are adjustable. It also filters textarea input: replaces non-alphanumeric characters with spaces, removes extra spaces (multiple consecutive, leading and trailing) and blank lines. Final clean-up is performed onblur, when user clicks out of textarea.


Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: limitTextarea2.js


Paste this code into the HEAD section of your HTML document.


Paste this code into the BODY section of your HTML document

Leave a Response

(1 comment)

I am wondering if anyone can come up with a fix for the requirement of enter being pressed at the end of each line in order to get to the next line! (At least, that is the default behavior in my browser!) Any fixes to that would be more than welcome!

Susanne Nov 28, 2013