textarea maxlength
By default, textareas do not have a maxlength area like input elements do.
However, with jQuery and a simple script I wrote, you can set the maximum input
length of a textarea.
Click here to preview textarea maxlength (URL: /projects/textarea)
What it looks like
There are two ways to set the maxlength with my script.
One way is to simply set the maxlength attribute.
Or, if you prefer to have W3C-standard XHTML code (maxlength is not a standard
textarea attribute), you can set it via jQuery.
Step One: download jQuery and my script
In order to use my script, you must download jQuery and my small JavaScript
file:
http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js (URL:
http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js)
http://www.andrewpeace.com/projects/textarea/textarea-maxlength.js (URL:
http://www.andrewpeace.com/projects/textarea/textarea-maxlength.js)
And include them on your page by pasting this in the head tag:
Step Two: use it!
That's it! Now you can use the script however you want. If you want to use the
maxlength attribute, you can now use it. Or, you can use the jQuery function
maxLength to dynamically set the maximum input length. Passing an argument of
zero will remove any maxLength rules.
More Questions?
As always, if you have any more questions, please email me (URL: contact.html).
I am always glad to answer questions and work on custom scripts.