jQuery Character Counter For Input Fields CW Charcount - Download jQuery Character Counter For Input Fields - CW Charcount

Download jQuery Character Counter For Input Fields – CW Charcount

Posted on

This time I will share jQuery Plugin and tutorial about jQuery Character Counter For Input Fields – CW Charcount, hope it will help you in programming stack.

jQuery Character Counter For Input Fields CW Charcount - Download jQuery Character Counter For Input Fields - CW Charcount
File Size: 17.3 KB
Views Total: 962
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

CW Charcount is a jQuery plugin that creates a decreasing character counter to limit the amount of text that is permitted in an input filed.

How to use it:

1. Include the latest version of jQuery library and jQuery CW Charcount plugin at the bottom of your document.

1 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
2 <script src="src/cw-charcount.js"></script>

2. Create an input field with maxlength attribute in the document.

1 <input type="text" name="name" id="name" maxlength="50">

3. Create a character counter next to the input field.

1 $('input[maxlength]').CWCharCount();

4. Sample CSS to style th character counter.

01 .cw_count {
02   border: 1px solid #b0b1b3;
03   color: #666666;
04   margin-left: 5px;
05   padding: 4px;
06 }
07  
08 .cw_count_warning {
09   border: 1px solid #c10000;
10   color: #c10000;
11 }

5. Available options.

01 $('input[maxlength]').CWCharCount({
02  
03   // This class is applied to the count field on startup and allows you to set the styles needed for it to blend in with your current site styling.
04 default_class   : 'cw_count',
05  
06 // The number of characters remaining before the warning class is added to the count object.
07 warning_level : 15,
08  
09 // This class is added to the count field once the warning level has been reached. It is removed if the character count increases above the warning level.
10 warning_class : 'cw_count_warning'
11  
12 });

Change log:

2016-03-17

  • Added AMD compatibility to the plugin

This awesome jQuery plugin is developed by clivewalkden. For more Advanced Usages, please check the demo page or visit the official website.

source : jqueryscript.net