Word Count (or Character count) for an input field

How would I create a word/character count field to count down characters used when typed into an input filed.

i.e. input field has a maxChar=255. I want the user to see the chars count down from 255, so they’ll know how many they have left.

I figure it would be along the lines of wordCountField=maxChar-currentNumOfChars…would that be right?

Thanks.