Here’s some additional info that will help.
The target property is required, and that’s as minimal as it might be.
characterCount({
target: document.getElementById('default')
});
Here are all of the default properties for the counter:
characterCount({
target: document.getElementById('counter'),
showOnInit: true,
direction: 'up',
max: Number.MAX_VALUE,
preventOverrun: false,
message: 'Please enter less characters'
});
You can have the counter remain hidden until something is typed:
characterCount({
target: document.getElementById('dontShow'),
showOnInit: false
});
To have a max of 10 characters, you would use this:
characterCount({
target: document.getElementById('maxChars'),
max: 10
});
You can style the error class, so that you can provide a visual indication of what’s going on:
.error {
color: red;
}
.error div {
display: inline;
margin-left: 1em;
}
characterCount({
target: document.getElementById('dontPrevent'),
max: 10,
preventOverrun: false
});
Or if you don’t want the error message to appear:
characterCount({
target: document.getElementById('dontPrevent'),
max: 10,
preventOverrun: false,
message: ''
});
You can have it count down from a certain maximum too:
characterCount({
target: document.getElementById('countingDown'),
direction: 'down',
max: 10
});
And you can have the counter go in to negative numbers too, by disabling the overrun prevention.
characterCount({
target: document.getElementById('countingDownOverrun'),
direction: 'down',
max: 10,
preventOverrun: false
});