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.
This can be done several ways but here is a link to some simple source code. The only for sure way to know how SO does it is to look into there compressed javascript.

<http://javascript.internet.com/forms/character-counter.html>