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:
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:
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 | |