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.
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);
}
Written by techval
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#