Call: (209) 560-6611

Word Counter JavaScript

Date: June 3, 2012 Author: ang Category: Affordable Web Design Tutorials Tags: Comments: 0

Here is a free word counter tool using JavaScript. Feel free to copy the code snippet below and use it on your own web page. Here is the word counter tool in action.

Word Counter JavaScript code

Place this block of code in the head section of your HTML document:

 Javascript |  copy code |? 
1
2
<script language="javascript">
3
function countWords(){
4
	document.form1.wordcount.value = document.form1.inputString.value.split(' ').length;
5
}
6
</script>
7

Place this block in the body section of your HTML Document:

 Javascript |  copy code |? 
1
2
<form name="form1" method="post">
3
<textarea name="inputString" cols="65" rows="20"></textarea>
4
<br>
5
<input type="button" name="Convert" value="Count Words" onClick="countWords();"> 
6
<input name="wordcount" type="text" value="" size="6">
7
</form>
8

Leave a Reply

Your email address will not be published. Required fields are marked *

Before you post, please prove you are sentient.

What is 6 times 3?

Before you post, please prove you are sentient.

what is 7 plus 5?