Text Area Max Length Counter

Posted on 2004-11-29
Last Modified: 2013-12-24
Does anyone have any code for a counter that sits below a textarea and increments every time the user inputs characters in the text area ?

for Example...

Text Area


30 / 250 Characters


Question by:jturkington
    LVL 5

    Accepted Solution

    this is what you are looking for ... enjoy
    LVL 14

    Assisted Solution

    by:Renante Entera
    Hello jturkington!

    Try to run this code :

    <script language="JavaScript">
    function textCounter(field, countfield, maxlimit)
      if (field.value.length > maxlimit)
        field.value = field.value.substring(0, maxlimit);
        countfield.value = field.value.length;

    <cfparam name="maxlength" default="250">

    <form name="form1">
      Remarks :
      <textarea name="message" onKeyDown="textCounter(this.form.message,this.form.txtlength,#maxlength#);" onKeyUp="textCounter(this.form.message,this.form.txtlength,#maxlength#);"></textarea>
      <input readonly type="text" name="txtlength" size="3" value="0"> / #maxlength# CHARACTERS

    Hope this helps you.  Just try it.

    eNTRANCE2002 :-)

    Author Comment

    Thanks guys

    Featured Post

    Scale it in WD Gold

    With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

    Join & Write a Comment

    Suggested Solutions

    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now