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

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

Answer: 
Probably something like (with jQuery):

```
$('#txtbox').keypress(function() {
    var max = 500;
    var textLen = $(this).val().length;
    var textLeft = max - textLen;
    $('#charCount').text(
        textLeft + ' character' + (textLeft == 1 ? '' : 's') + ' left'
    );
});

```

(I know it's lazy to not actually look and see how they do it, but here's a working example: <http://jsfiddle.net/FishBasketGordo/hqex8/>)
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>