JavaScriptCharacterCount
An amazingly small, dependency-less utility for counting input characters. Less than 1 Kbyte!
Usage
Count Up
Enter Text ... Element contains characters.
Count Down
Enter Text ... Element can contain up to more characters.
See 'examples' for a real life example.
CDN
For Development: https://rawgit.com/PascaleBeier/JavaScriptCharacterCount/2.1.0/dist/javascript-character-count.min.js
For Production: https://cdn.rawgit.com/PascaleBeier/JavaScriptCharacterCount/2.1.0/dist/javascript-character-count.min.js
Download
Downloads can be found at the Releases Page.
npm: npm i javascript-character-count
API
Options
The array passed as second argument:
max: 255 // int, required. The callback is fired after this number is reached (or subtracted to 0 with invert = true) output: document // element, required invert: true // invert counting
Callbacks
Most of the time, you will want something to happen when a user enters a certain number of characters.
You can realize this with callbacks. If you want a simple alert()
to popup, you can do:
Enter Text ... Element contains characters.
Changelog
See CHANGELOG
Contributing - Development Setup
# Get the source $ git clone https://github.com/PascaleBeier/JavaScriptCharacterCount$ cd JavaScriptCharacterCount# Install devDependencies $ npm i# Compile src/ to dist/ $ npm run dev# Build for publishing $ npm run build
start editing src/javascript-character-count.js and open up examples/index.html in your browser.
License
The MIT License.