How to count WORDS in JavaScript ? OR How to make word counter in JavaScript ?

Description:- Few days before I made and upload character counter which is right here ( ) and today  Through this example you can easily make your own word counter not the character counter. In character counter user can easily know how many character he have written, but through word counter one can easily find out how many words he have written.

<title>Word counter</title>
<textarea name="comment" onkeyup="wordcount(this.value)" rows="5" cols="50"></textarea> <br/>

document.write("<input type=text id=aaa readonly/>");
function wordcount(type) 
var words = type.split(/\s/);
var bbb = words.length;
var ccc = document.getElementById('aaa');
ccc.value = bbb;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s