Last Updated: November 20, 2018
· techval

How to create a word count tool for counting the number of words in a research project abstract

While creating a post to teach final year students how to write abstracts for their research projects, I decided to develop a tool to guide them in writing an abstract.

View demo

Here is the implementation:

   function WordCount() {
    var inp = document.getElementById('txtabstract').value;

    var regex = /\s+/gi;
    var wordcount = jQuery.trim(inp).replace(regex, ' ').split(' ').length;