janet wrote on 08 sep 2003 in microsoft.public.inetserver.asp.general:
how can i count how many words have i written in a text
area???
Like taking an example ... i am writing in this textarea
of microsoft usergroup. and say in total i have written 50
words .. how can find out this information?
When you have submitted the string to serverside ASP
[If you want a clientside solution please go elsewhere]
first trim and change all multiple whitespace to single spaces,
then count your spaces and add one:
Serverside Jscript:
s = " blah blah blah "
s = s.replace(/(^\s+)|(\s+$)/g,"")
s = s.replace(/\s+/g," ")
s = s.split(" ")
l = s.length - 1 + 1
===================
more concise:
s = " blah blah blah "
l = s.replace(/(^\s+)|(\s+$)/g,"").replace(/\s+/g," ")
.split(" ").length
// make one line of the two above
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)