#! code JavaScript Text Length

Enter some text into the textarea and the tool will tell you the number of characters it contains. It first trims the text so the surrounding white space isn't counted.

Source code.

The Form

<form onsubmit="return false;" action="" id="textLengthCalc"> <textarea name="textarea" rows="10" cols="68" onkeydown="textCounter()" onkeyup="textCounter()"></textarea> <input readonly="readonly" size="15" type="text" name="len" maxlength="10" value="0" /> </form>

The JavaScript

function textCounter(){
 var area = document.getElementById('textLengthCalc');
 area.len.value = area.textarea.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '').length;
}

JavaScript Text Length Tool.