Home » » Textarea counter with javascript

Textarea counter with javascript

Written By Unknown on Sabtu, 20 Agustus 2011 | 01.37

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
 


Characters Left =
Share this article :

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger