jQuery plugin: character count for textareas
<p>i am using the below plugin for counting the char in the textarea but the only feature i would like to add is that when the character is exceed the limit then it should stop and not allow any more characters to be entered.. so should i just return when it match the allowed character?</p>

<p>below is the sample link with source code.</p>

<p><a href="http://cssglobe.com/lab/charcount/01.html" rel="nofollow">http://cssglobe.com/lab/charcount/01.html</a></p>

<pre><code>(function($) {

    $.fn.charCount = function(options){

        // default configuration properties
        var defaults = {    
            allowed: 140,       
            warning: 25,
            css: 'counter',
            counterElement: 'span',
            cssWarning: 'warning',
            cssExceeded: 'exceeded',
            counterText: ''
        }; 

        var options = $.extend(defaults, options); 

        function calculate(obj){
            var count = $(obj).val().length;
            var available = options.allowed - count;
            if(available &lt;= options.warning &amp;&amp; available &gt;= 0){
                $(obj).next().addClass(options.cssWarning);
            } else {
                $(obj).next().removeClass(options.cssWarning);
            }
            if(available &lt; 0){
                $(obj).next().addClass(options.cssExceeded);
            } else {
                $(obj).next().removeClass(options.cssExceeded);
            }
            $(obj).next().html(options.counterText + available);
        };

        this.each(function() {              
            $(this).after('&lt;'+ options.counterElement +' class="' + options.css + '"&gt;'+ options.counterText +'&lt;/'+ options.counterElement +'&gt;');
            calculate(this);
            $(this).keyup(function(){calculate(this)});
            $(this).change(function(){calculate(this)});
        });

    };

})(jQuery);
</code></pre>
