Today i will explain you how we can count the remaining characters in text area. This is the same as we see in old twitter.
First i show u by pictures how this looks like:-
When the remaining characters becomes 0 or negative then it shows in red color.
The code of the file looks like this:-
So i am calling count function on onkeydown and onkeyup so that when the user enters a character the function will be called.
I have also used if and else to change the color of remaining characters. If the remaining characters or variable result is greater than 0 then ok if it is equal to zero or negative then i changed the font to red.
You can download the source code from here