Question: How does Stackoverflow do the character counter saying xyz characters left?

![enter image description here](https://i.stack.imgur.com/fZD01.png)

Answer: 
HTML:

```
<textarea id="text" onkeyup="charCount(this);"></textarea>
<span id="chars"></span>

```

JS:

```
var maxChars = 500;
function charCount(el) {
   document.getElementById('chars').innerText = maxChars - this.value.length;
}

```

not tested, but that's the basics.
Have a look at this page on one of my sites <http://www.bestvaluesolicitors.com/contact-us>

Peek at the JS - you are looking for this function:

`function ml(id,max,repeat){if($F(id).length>max){$(id).value=$F(id).substring(0,max);}$(id).next('div').update($F(id).length+' / '+max+' characters');if(repeat==true){setTimeout('ml("'+id+'",'+max+','+repeat+')',500);}}`

Esentially it is a combination of a timer and counting the length of text in the `textarea`