# Counting characters in a text input box

**URL:** <https://forum.wixstudio.com/t/counting-characters-in-a-text-input-box/27484>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [March 5, 2018, 8:48am UTC](https://forum.wixstudio.com/t/counting-characters-in-a-text-input-box/27484 "2018-03-05T08:48:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![npiquito](https://avatars.discourse-cdn.com/v4/letter/n/b2d939/32.png) [@npiquito](https://forum.wixstudio.com/u/npiquito)\
**Post date:** [March 5, 2018, 8:48am UTC](https://forum.wixstudio.com/t/counting-characters-in-a-text-input-box/27484/1 "2018-03-05T08:48:52Z")

</div>

Hello all. I have a text input box with a character limit. Is there a way to display the characters remaining to the user as they type (in real-time)?

Thx  
Nick

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/system/32/86885_2.png) [@system](https://forum.wixstudio.com/u/system)\
**Post date:** [March 5, 2018, 10:41am UTC](https://forum.wixstudio.com/t/counting-characters-in-a-text-input-box/27484/2 "2018-03-05T10:41:25Z")

</div>

Hi,  
Sure… add a text element that shows the number of characters and use ’ [onChange](https://www.wix.com/code/reference/$w.TextBox.html#onChange) ’ for the text input box to read the number of characters inside and update the text element.  
Let’s say we have ‘text1’ and ‘#input1’, something like:

```javascript
export function input1_change() {
    const remainingLength = $w('#input1').maxLength - $w('#input1').value.length;
    $w('#text1').text = `Only ${remainingLength} remaining characters.`;
}

```

Hope this helps,  
Liran.

---

<div class="post-metadata">

**Author:** ![npiquito](https://avatars.discourse-cdn.com/v4/letter/n/b2d939/32.png) [@npiquito](https://forum.wixstudio.com/u/npiquito)\
**Post date:** [March 5, 2018, 2:18pm UTC](https://forum.wixstudio.com/t/counting-characters-in-a-text-input-box/27484/3 "2018-03-05T14:18:28Z")

</div>

Works well! Many thanks Liran.

---

<div class="post-metadata">

**Author:** ![dutraphill](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dutraphill/32/13470_2.png) [@dutraphill](https://forum.wixstudio.com/u/dutraphill)\
**Post date:** [July 28, 2020, 8:41pm UTC](https://forum.wixstudio.com/t/counting-characters-in-a-text-input-box/27484/4 "2020-07-28T20:41:28Z")

</div>

This is exatly what I need Liran! But where exactly in Wix Corvid do I apply this code? Thanks!

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [July 28, 2020, 11:14pm UTC](https://forum.wixstudio.com/t/counting-characters-in-a-text-input-box/27484/5 "2020-07-28T23:14:39Z")

</div>

Hello Phill,

you can put this code into the CODE-SECTION of your choosen site-page.  
Before you can do it, make sure that you have activated “Dev-Mode”.  
If “dev-Mode” is OFF, then you can’t paste any codings into your project.

Once you have activated the “Dev-Mode” (Developer-Mode), then you will see the CODE-Section on the lower End of your screen.

Good luck and happy coding!😁
