Snippet Name: Count Textbox Chars
Description: Count the number of characters remaining in a textbox.
Comment: (none)
Language: JAVASCRIPT
Highlight Mode: JAVASCRIPT
Last Modified: February 27th, 2009
|
<script type="text/javascript">
FUNCTION textCounter(textarea, counterID, maxLen) {
cnt = document.getElementById(counterID);
IF (textarea.value.length > maxLen){
textarea.value = textarea.value.substring(0,maxLen);
}
cnt.innerHTML = maxLen - textarea.value.length;
}
</script>
<form action="whatever.php">
<textarea name="text_area" cols="50" rows="5"
onKeyUp="textCounter(this,’count_display’,3500);" >
onBlur="textCounter(this,’count_display’,3500);" >
|