Fork me on GitHub

KWCount

A small and fancy jQuery plugin for displaying char counts for inputs and textareas.
Some times, when we fill forms, we have restrictions on field characters count. For example, short description should be less then 160. How can we inform user about how many chars left? This simple plugin provides a cool way of information about that. Try it yourself!

Basic usage.

All that you need is to add jquery library to your page (if you don't have done it already), add kwcount.js and kwcount.css:

				<link href="kwcount.css" rel="stylesheet" type="text/css">
				<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
				<script type="text/javascript" src="kwcount.js"></script>
			

After that, initialize a plugin on inputs and textareas like this:

				$('input[type="text"],textarea').kwcount();
			

KWCount plugin can use 3 sources for maximum characters value:

Possible options.

KWCount can take some options when initializing.

More examples.

Showing only number of current chars, without maximum.

				$('#input3,#input4').kwcount({ show_max: false });
			


Prevent inputing chars after maximum count is reached. It's usefull when no maxlength attribute is specified on element.

				$('#input5,#input6').kwcount({ limit: true });
			


Set maxlength manualy, when initializing, ignoring element attributes and prevent inputing chars after maximum count is reached.

				$('#input7').kwcount({ maxlength: 25, limit: true });
$('#input8').kwcount({ maxlength: 45, limit: true });


Counting words instead of characters. If you do not set show_max to false, than a question mark will be showed instead of a maximum value.

				$('#input9').kwcount({ count_type: 'words' });
			

License

KWCount plugin licensed under the MIT and GPL licenses.