# Active character countdown

**URL:** <https://forum.inductiveautomation.com/t/active-character-countdown/77028>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [July 27, 2023, 5:10pm UTC](https://forum.inductiveautomation.com/t/active-character-countdown/77028 "2023-07-27T17:10:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cameron\_Nickle](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Cameron\_Nickle](https://forum.inductiveautomation.com/u/Cameron_Nickle)\
**Post date:** [July 27, 2023, 5:10pm UTC](https://forum.inductiveautomation.com/t/active-character-countdown/77028/1 "2023-07-27T17:10:09Z")

</div>

Hi all,

I'm currently working on putting some additions on my project and I wanted to add a small counter that tells the user how many characters they have left to input into a text field in real time.  
Currently I have a binding on a label component that calculates '250 - len(currentString)' and this is refreshed via a message handler on the textArea itself. Note: 250 is the amount of space I allocated in a data base column and the string will only be saved if it is less than 250. The problem is: it will refresh the result but on inconsistent timings it seems.  
I'm not entirely sure if what I want to do is possible but I'd like to have it so that when the user inputs any character the counter goes down instantly as they're typing.

Current label binding:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/a/4a1d823469e700b5abb59f8627b6e07e946df38c.png)

message handler:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/8/88449778bfcff9536560aec51d56db1d1e5a815f.png)

textArea simply sends a message on a handful of different events at the moment for both keyboard and touch screen.

Thank you,

Cam

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 27, 2023, 5:18pm UTC](https://forum.inductiveautomation.com/t/active-character-countdown/77028/2 "2023-07-27T17:18:35Z")

</div>

1. uncheck the `deferUpdate` checkbox in the text field's property. This will make the `text` property update in real time
2. bind a label to the text field's `text` property and use its length there. Make it an expression binding that looks something like this: `250 - len({../textField.text})` (use the property browser to get the right path)
3. be careful with naive approaches like this. Some characters are bigger than just one byte. Depending on expected languages and encodings, you might need to use a more robust method.

edit: Just noticed you're using a text area and not a text field. But it should work the same way.

---

<div class="post-metadata">

**Author:** ![Cameron\_Nickle](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Cameron\_Nickle](https://forum.inductiveautomation.com/u/Cameron_Nickle)\
**Post date:** [July 27, 2023, 5:33pm UTC](https://forum.inductiveautomation.com/t/active-character-countdown/77028/3 "2023-07-27T17:33:14Z")

</div>

For what I wanted it to do it is working, Thank you 🙂

What suggestions do you have to make it more robust?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 27, 2023, 5:51pm UTC](https://forum.inductiveautomation.com/t/active-character-countdown/77028/4 "2023-07-27T17:51:18Z")

</div>

If you're only going to save the content if it is less than 250 characters, it might be best to actually limit the content of the input.

See [this post](https://forum.inductiveautomation.com/t/ignition-perspective-limit-number-of-characters-allowed-in-input-text-field/37937/4) for how to limit the number of characters an input will accept.

---

<div class="post-metadata">

**Author:** ![Cameron\_Nickle](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Cameron\_Nickle](https://forum.inductiveautomation.com/u/Cameron_Nickle)\
**Post date:** [July 27, 2023, 6:03pm UTC](https://forum.inductiveautomation.com/t/active-character-countdown/77028/5 "2023-07-27T18:03:14Z")

</div>

That is also a nice addition to the view. Thank you 🙂
