# How can I add code to count character of user input? 

**URL:** <https://forum.wixstudio.com/t/how-can-i-add-code-to-count-character-of-user-input/1328>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [May 7, 2021, 10:33am UTC](https://forum.wixstudio.com/t/how-can-i-add-code-to-count-character-of-user-input/1328 "2021-05-07T10:33:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ouzylmz](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ouzylmz/32/28204_2.png) [@ouzylmz](https://forum.wixstudio.com/u/ouzylmz)\
**Post date:** [May 7, 2021, 10:33am UTC](https://forum.wixstudio.com/t/how-can-i-add-code-to-count-character-of-user-input/1328/1 "2021-05-07T10:33:20Z")

</div>

Hi, I want to add a character count for user input with html code, How can I do it?

---

<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:** [May 7, 2021, 10:53am UTC](https://forum.wixstudio.com/t/how-can-i-add-code-to-count-character-of-user-input/1328/2 "2021-05-07T10:53:11Z")

</div>

You don’t need HTML for it.  
All you need is —\> .length of your input-value.

---

<div class="post-metadata">

**Author:** ![ouzylmz](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ouzylmz/32/28204_2.png) [@ouzylmz](https://forum.wixstudio.com/u/ouzylmz)\
**Post date:** [May 7, 2021, 11:03am UTC](https://forum.wixstudio.com/t/how-can-i-add-code-to-count-character-of-user-input/1328/3 "2021-05-07T11:03:04Z")

</div>

Hi Dina,

How can I do it in a form ? sorry I am new

---

<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:** [May 7, 2021, 1:11pm UTC](https://forum.wixstudio.com/t/how-can-i-add-code-to-count-character-of-user-input/1328/4 "2021-05-07T13:11:45Z")

</div>

Ok, let’s imagine you have a —\> FORM !  
In your FORM, you will surely have an → INPUTFIELD.  
Into this INPUTFIELD you will surely want to insert a —\> VALUE.  
And of course you will have a button for —\> SUBMIT.

And you want to count the caracters of the entered —\> VALUE, right?

```javascript
$w.onReady(()=>{
	$w('#submitButton').onClick(()=>{
		setTimeout(()=>{
			let myValue = $w('#input1').value
			let charCount = myValue.length 
			console.log("Char-Count: ", charCount)
		},50);
	});
});

```

---

<div class="post-metadata">

**Author:** ![ouzylmz](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ouzylmz/32/28204_2.png) [@ouzylmz](https://forum.wixstudio.com/u/ouzylmz)\
**Post date:** [May 7, 2021, 10:38pm UTC](https://forum.wixstudio.com/t/how-can-i-add-code-to-count-character-of-user-input/1328/5 "2021-05-07T22:38:26Z")

</div>

Hi Dima

thank you for your code, but I wanna show Char-count at real time, not when submision. Please look at photo of my form. I mean, when user enter input as ‘‘ORF sequence(textbox)’’, then Char-count should be seen at the bottom .

 ![](https://us1.discourse-cdn.com/wix/original/3X/9/5/95a7cdacaa3b10e747375c8f64c6b74a29afff49.png)

---

<div class="post-metadata">

**Author:** ![workiapps](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/workiapps/32/25032_2.png) [@workiapps](https://forum.wixstudio.com/u/workiapps)\
**Post date:** [May 13, 2021, 4:24pm UTC](https://forum.wixstudio.com/t/how-can-i-add-code-to-count-character-of-user-input/1328/6 "2021-05-13T16:24:10Z")

</div>

```javascript
export function textBoxshortDescription_keyPress(event) {
    let characterRemaining = $w('#textBoxshortDescription').maxLength - $w('#textBoxshortDescription').value.length;
    
$w('#textCharacterCount').text = `${characterRemaining} Characters Remaining`
}

```

Note: Set the character limit in Text Box Settings
