Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cballou/0d8507970e6f03c80461305a29871cbc to your computer and use it in GitHub Desktop.
Save cballou/0d8507970e6f03c80461305a29871cbc to your computer and use it in GitHub Desktop.
/**
* Default config values. Can be overridden globally.
*
* maxLength [int] - The maximum length of the input, textarea, or editable field
* countWords [bool] - Whether to count by word or by length
* countContainer [jQuery element | DOM selector string] - The container to display the count and message
* countDown [bool] - Whether the counter displays a remaining count or current count
* errorClass [string] - The class to apply to countContainer when an overage occurs
* countWordStr [string] - The string to use after the word length
* countLengthStr [string] - The string to use after the length
*/
$.fn.textCounter.defaults = {
maxLength: 140,
countWords: true,
preventNegative: false,
countContainer: null,
countDown: true,
errorClass: 'error',
countWordStr: 'words remaining',
countLengthStr: 'characters remaining'
};
// specify your special options
var options = {};
// your target element can be an input, textarea, or contendEditable container
$('#my-target-elem').textCounter([options]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment