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
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
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#