Counting characters in a text input box

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

Hi,
Sure… add a text element that shows the number of characters and use ’ 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:

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

Hope this helps,
Liran.

Works well! Many thanks Liran.

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

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!:grin: