Hello friends. Here is a simple script to count characters of a textarea.
The Javascript
<script type="text/javascript">
function counter(txtfield,countfield,maxlimit) {
if (txtfield.value.length > maxlimit)
txtfield.value=txtfield.value.substring(0,maxlimit);
else
countfield.value = maxlimit - txtfield.value.length;
}
</script>
The Html Form
<form name="counterForm">
<textarea name="msg" onKeyUp="counter(this,charLeft,50)">
</textarea>
Characters Left =
<input readonly="readonly" type="text" name="charLeft"
size="4" maxlength="4" value="50" style="border:0" >
</form>
The Example
Posting Komentar