You just need the bolded text…
<html>
<HEAD>
<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>
</HEAD>
<body>
<center>
<form action=”whatever.php”>
<textarea name=”text_area” cols=”50″ rows=”5″ onKeyUp=”textCounter(this,’count_display’,3500);” >
onBlur=”textCounter(this,’count_display’,3500);” >
</textarea>
<br>
<span id=”count_display”>3500</SPAN> characters remaining
<input type=”submit” value=”Submit”>
</form>
</center>
</body>
</html>
Apr 22, 2010 at 3:41 pm |
Nice code . I have implemented a similar stuff using Jquery . You can find the tutorial here :
http://youhack.me/2010/04/22/live-character-count-with-progress-bar-using-jquery/
The difference with this one is that i have implemented a progress bar based on the number of characters entered .
Enjoy !