By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,238 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,238 IT Pros & Developers. It's quick & easy.

display number of characters in textarea box

P: n/a
i wish to count number of characters in textarea box during typing in and
display it somewhere in html page. so the number will increase during
writing.

is it possible to do it by javascript?

Thanks a lot.

Tony
Sep 11 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a

"tony wong" <x3*@netvigator.com> wrote in message
news:43********@127.0.0.1...
i wish to count number of characters in textarea box during typing in and
display it somewhere in html page. so the number will increase during
writing.

is it possible to do it by javascript?


create an event for the onchange value of the textarea, get the value of the
textarea and then count the chars.

HTH
Sep 11 '05 #2

P: n/a
Zoe Brown said the following on 9/11/2005 2:31 PM:
"tony wong" <x3*@netvigator.com> wrote in message
news:43********@127.0.0.1...
i wish to count number of characters in textarea box during typing in and
display it somewhere in html page. so the number will increase during
writing.

is it possible to do it by javascript?

create an event for the onchange value of the textarea, get the value of the
textarea and then count the chars.


Use the onkeyup instead, and after onkeyup you check the character
count. onchange will only fire *after* the textarea has lost focus.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Sep 11 '05 #3

P: n/a
tony wong wrote:
i wish to count number of characters in textarea box during typing in and
display it somewhere in html page. so the number will increase during
writing.
is it possible to do it by javascript?
Thanks a lot.
Tony


http://www.google.com/search?hl=en&l...ox&btnG=Search
2nd hit (google is your friend)

http://www.cs.tut.fi/~jkorpela/forms/textarea.html

Mike
Sep 11 '05 #4

P: n/a
"Randy Webb" <Hi************@aol.com> wrote in message
news:T_********************@comcast.com...
Zoe Brown said the following on 9/11/2005 2:31 PM:
"tony wong" <x3*@netvigator.com> wrote in message
news:43********@127.0.0.1...
i wish to count number of characters in textarea box during typing in anddisplay it somewhere in html page. so the number will increase during
writing.

is it possible to do it by javascript?

create an event for the onchange value of the textarea, get the value of the textarea and then count the chars.


Use the onkeyup instead, and after onkeyup you check the character
count. onchange will only fire *after* the textarea has lost focus.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly


<html>
<head>
<title>count.htm</title>
<script type="text/javascript">
function count(that) {
window.status = that.value.length;
}
</script>
</head>
<body>
<form>
<textarea name="text" cols="50" rows="10" onkeyup="count(this)"></textarea>
</form>
</body>
</html>
Sep 12 '05 #5

P: n/a
McKirahan said the following on 9/11/2005 8:21 PM:
"Randy Webb" <Hi************@aol.com> wrote in message
news:T_********************@comcast.com...
Zoe Brown said the following on 9/11/2005 2:31 PM:
"tony wong" <x3*@netvigator.com> wrote in message
news:43********@127.0.0.1...
i wish to count number of characters in textarea box during typing in
and
display it somewhere in html page. so the number will increase during
writing.

is it possible to do it by javascript?
create an event for the onchange value of the textarea, get the value of
the
textarea and then count the chars.


Use the onkeyup instead, and after onkeyup you check the character
count. onchange will only fire *after* the textarea has lost focus.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly

<html>
<head>
<title>count.htm</title>
<script type="text/javascript">
function count(that) {
window.status = that.value.length;


Why the status bar? That will utltimately fail in Mozilla based browsers
that have the ability to script the status bar disabled.
And please fix your OE so that it does not quote signatures.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Sep 12 '05 #6

P: n/a
ASM
Zoe Brown wrote:
"tony wong" <x3*@netvigator.com> wrote in message
news:43********@127.0.0.1...
i wish to count number of characters in textarea box during typing in and
display it somewhere in html page. so the number will increase during
writing.

is it possible to do it by javascript?

create an event for the onchange value


Not at all !
use : onkeyup
of the textarea, get the value of the
textarea and then count the chars.


<textarea
onkeyup="document.getElementById('count').innerHTM L=this.value.length;">
</textarea>
<p id="count">
--
Stephane Moriaux et son [moins] vieux Mac
Sep 12 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.