Textarea Character Counter

Posted on Monday, February 25, 2008 11:01 AM by K. Latham
Quick notes on creating a character counter for a TEXTAREA (Similar to Twitter)
<SCRIPT LANGUAGE="Javascript">
function counttweet() {
var lngCount = document.FORMNAME.TEXTAREANAME.value.length;
document.getElementById("TweetCnt").innerHTML = "Count: " + lngCount + "/140";
}
</SCRIPT>
Inside TEXTAREA tag add:
onkeyup="counttweet();" onFocus="counttweet();" onBlur="counttweet();"
Display count in DIV:
<div id=TweetCnt>Count: 0/140</div>