Count: 0
Description
There are times when developing websites that you may want to limit the number of characters that you type. One example of this would be the meta tag description. Most search engines are designed to display a limited description for each result, so you may want to make sure your first 150 characters are very descriptive.
This tool uses an HTML textarea with an onkeyup attribute and a very simple function to count the number of characters as they're being typed. The result is then inserted into a span element.
If you would like to use this tool on your website, I've included the HTML and JavaScript below.
HTML
<textarea id="count_box" cols="90" rows="5" onkeyup="countChar(this.value)"></textarea>
<p>Count: <span id="count_number">0</span></p>
JavaScript
<script type="text/javascript">
var cnt_num = document.getElementById("count_number");
function countChar(str) {
cnt_num.innerHTML = str.length;
}
</script>