jaehess/limitedtextarea-js
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
USAGE:
1.) Include this script after Prototype in the HEAD section of your HTML page
<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script src="/javascripts/limitedtextarea.js" type="text/javascript"></script>
2.) Choose your implementation method
A.) Unobtrusive (silent):
Add the "rel" attribute to your textarea tag with a value of "limited". This will limit the textarea to default of 300 words.
Example:
<textarea cols="40" id="comment" name="comment" rel="limited" rows="20"></textarea>
Adding "limited[##]" will allow you to override the limit on that textarea.
Example:
<textarea cols="40" id="comment" name="comment" rel="limited[250]" rows="20"></textarea>
B.) Inline:
You can also call the Limited TextArea Inline in your HTML.
Options include:
silent: true | false "true is default. false is required to run inline"
id: dom_id of element "pass in the id of the textarea you wish to limit words on."
limit: 300 "pass in the limit on the word count for this textarea. Defaults to 300"
Example:
<textarea cols="40" id="comment" name="comment" rows="20"></textarea>
<script type="text/javascript" charset="utf-8">
limited = new LimitedTextArea({
silent: false,
id: 'comment'
});
</script>