I'm trying to do a "twitter like" character counter in a contenteditable
div
. I want to limit the user to typing a max of 140 characters.
I used jQuery to count the characters and show the remaining, but it doesn't count the Enter key (new line) as a character. I need to count the new lines too.
I tried to use a textarea
, but I need to specify the max-height
for the scrollbar be visible only on the max-height. There is no limit of lines or characters.
DEMO: https://jsfiddle.net/oLomzakh/
Can you help me figure out how to include the new line count on the character count?