Skip to main content

Max Char

Description

Provide a help text that displays how many characters remain available in a text area.

Sample

Include the following java scripts on your page.  The option max: 300 states that we allow up to 300 characters in this textarea.

<script type="text/javascript"
    src="//www.ucsd.edu/common/cwp/active-cherry/lib/jquery.maxchar-1.0/jquery.maxchar-min.js" ></script>
<script type="text/javascript">
(function($) {
    $(document).ready(function() {
         $(".maxchar").maxchar( {
             max : 300
         } );
    });
})(jQuery);
</script>

In this case, we specified that all textarea elements with class maxchar will have this feature. By default, the widget will look for the first element with class help after the textarea and put the messages here.

<textarea class="maxchar"></textarea>
<span class="help"></span>

If you want to put the help text in another element other than help class. Pass in another option such as the following: infoClass: maxchar_help to let the widget to put the message in an element with class maxchar_help