This is a small Javascript class I wrote a while ago. It hooks up to a text-area or a text input and limits the amount of characters you can write in it while displaying a count-down of the remaining characters… It is cross-browser and uses a custom event to check for changes in the text (so that it works, for example, if you paste text in the textarea). Anyway, here is the code:
The full documentation is here.