# Textinput, count letters

**URL:** <https://forum.kirupa.com/t/textinput-count-letters/255206>\
**Category:** Uncategorized\
**Created:** [March 20, 2008, 1:02am UTC](https://forum.kirupa.com/t/textinput-count-letters/255206 "2008-03-20T01:02:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![teekaay](https://avatars.discourse-cdn.com/v4/letter/t/e19b73/32.png) [@teekaay](https://forum.kirupa.com/u/teekaay)\
**Post date:** [March 20, 2008, 1:02am UTC](https://forum.kirupa.com/t/textinput-count-letters/255206/1 "2008-03-20T01:02:11Z")

</div>

Hi.  
Sorry for the title, I can’t come up with a good one for my problem.

I’m having problems with some code i’m working on.  
I’ll try to explain as good as I can.

I have a textinput that updates a textfiled on change.  
I also have a textfield that shows how many chars you have typed.

```auto
 
on(change)
{
     _root.test_txt.text = this.text;
     _root.chars_txt.text = this.text.length;
}

```

What I want is that when (for example) the letter A is typed it counts it two times.  
KIRUPA becomes 7 letters.

I was thinking of having something like numTest++

```auto
 
on(change)
{
     myString = this.text;
     for(var i:Number = 0; i < myString.length; i++)
     {
          if(myString.charAt(i) == "A")
          {
               numTest++
          }
      }
     _root.chars_txt.text = this.text.length + numTest;
 
}

```

But I only want the thing to count the letter once. Now it adds numTest++ on the same letter when typing some more. ADDD becomes 8 chars. (Should be 5).

FLA can be downloaded here: [http://www.lazeeonline.com/help.zip](http://www.lazeeonline.com/help.zip)

Thnx in advance.
