Category: >> JavaScript >> Count Textbox Chars Bookmark and Share

<< lastnext >>

Snippet Name: Count Textbox Chars

Description: Count the number of characters remaining in a textbox.

Comment: (none)

Author: CoderZone
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;
<form action="whatever.php">
<textarea name="text_area" cols="50" rows="5" 
onKeyUp="textCounter(this,’count_display’,3500);" >
onBlur="textCounter(this,’count_display’,3500);" >
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© | users online: 7