Last Updated: November 20, 2018
·
2.421K
· 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;      


    $("#labelcount").html(wordcount);
}

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside