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
Is very useful to remove whitespaces from the beginning and end of the string usign $.trim(). You can use keyup event for a realtime counting.
$.trim()
keyup
$('#name').keyup(function(){ var words = $.trim($(this).val()).split(' '); console.log(words.length); });