how to show a live updated character count of textbox in page with javascript?

$1
=
$0
+
$1
$1 Bitcoin bounty has been announced by author.
$0 has been already awarded by author.
$1 remains available.
1

I want to show the user how many characters they have typed in the text box.

1 Answer - total earned - 4.3 mBTC ($0.95 USD)

1
=
1
=
$0.95
1 tip with total amount of 4.3 mBTC($0.95 USD) have been sent by alex

Pretty simple solution, with a few assumptions: 1. you load javascript functions 2. users have modern browsers

On the text box use this code: onkeyup="charcountupdate(this.value)"

After the text box, add this where you want to display the counter: <span id=charcount></span>

(can also use div instead of span)

And on the javascript file add these lines:

function charcountupdate(str){
var lng = str.length;
document.getElementById("charcount").innerHTML = lng + ' out of xxx characters';
}

see my example: http://codepen.io/borisplotkin/pen/RPwXeK

Hope this helps.

SEND BITCOIN TIPS

Boris, thanks again, sending you some coins right now!

1

Post Answer


Top 3 Tippers
Recent Tips

Will Bitcoin Tipping become a new Internet Culture?


Please share our story! THANK YOU!