I have a simple html text box. When I \"submit\" the form that the text box is in, I would like to get a variable with the number of words inside using Jqu
Using the regular expression below allow us to remove any kind of white space (single or multiples) so that the count is very accurate.
$('#name').keyup(function(){
var wordCount = $(this).val().split(/[\s\.\?]+/).length;
console.log(wordCount);
});
See this jQuery plugin I have developed:
https://github.com/mcdesignpro/maxLenght