This repository has been archived by the owner on May 20, 2021. It is now read-only.
Home
Wayne Boka edited this page Jul 12, 2014
·
5 revisions
jQuery plugin to count characters in a text field.
The maxlength attribute is supported in Internet Explorer 10+, Firefox, Opera 15+, Chrome, and Safari.
Note: The maxlength attribute of the <textarea> tag is not supported in Internet Explorer 9 and earlier versions, or in Opera 12 and earlier versions.
- jQuery > 1.0.0
Major.Minor.Patch
- Major - Breaks backwards compatibility
- Minor - Adds functionality without breaking backwards compatibility
- Patch - Bug fixes that are backwards compatible
Name | Type | Default | Accepts | Example |
---|---|---|---|---|
parentContainer | string | "div" | Any valid HTML element | "parentContainer": "p" |
charsClass | string | "charsRemaining" | Any string | "charsClass": "chars" |
position | string | "before" | "before" or "after" | "position": "after" |
debug | boolean | false | true or false | "debug": true |
debugMode | string | "console" | "alert" or "console" | "debugMode": "alert" |
clearConsole | boolean | false | true or false | "clearConsole": true |
Include the following code before the </body> tag:
1. <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> 2. <script type="text/javascript" src="jquery.count-chars.js"></script> 3. <script type="text/javascript" >$("textarea, input").countChars();</script>
Notes:
- Line 1 can be replaced by any link to a jQuery library version 1.0 or higher.
- Line 2 will point to the Count Chars plugin location in your file structure.
- Line 3 sets up the Count Chars plugin with the default values.
OR
Include the following code before the </head> tag:
1. <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> 2. <script type="text/javascript" src="jquery.count-chars.js"></script> 3. <script type="text/javascript" > 4. $(document).ready(function() { 5. $("textarea, input").countChars(); 6. }); 7. </script>
Notes:
- Line 1 can be replaced by any link to a jQuery library version 1.0 or higher.
- Line 2 will point to the Count Chars plugin location in your file structure.
- Line 5 sets up the Count Chars plugin with the default values.