Basically: assign a keyup
handler to the <textarea>
element, in it count the length of the <textarea>
and write the count to a separate <div>
if its length is shorter than a minimum value.
Here's is an example-
var min = 15;_x000D_
document.querySelector('#tst').onkeyup = function(e){_x000D_
document.querySelector('#counter').innerHTML = _x000D_
this.value.length < min _x000D_
? (min - this.value.length)+' to go...'_x000D_
: '';_x000D_
}_x000D_
_x000D_
body {font: normal 0.8em verdana, arial;}_x000D_
#counter {color: grey}
_x000D_
<textarea id="tst" cols="60" rows="10"></textarea>_x000D_
<div id="counter"></div>
_x000D_