Text Area Counter Using Javascript

I have created the text area counter character counter using  javascript. I’m sharing the script to you guys.


<script type="text/javascript">
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
countfield.value = maxlimit - field.value.length;
// End -->
<textarea cols="32 " rows="10" name="message" id="message" class="inputbox required" onkeydown="textCounter(this.form.message,this.form.remLen,500);" onkeyup="textCounter(this.form.message,this.form.remLen,500);" ></textarea><br /><input type="text" class="wordlimit" value="500" readonly="readonly" name=remLen size="5" maxlength="5">

Guys try and comment on this.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s