String.prototype.countWords = function(){
return this.split(/\s+\b/).length;
}
jQuery(document).ready(function($){
$('#field_typehereparagraph').keyup(function(){
var s = this.value;
var numWords = s.countWords();
document.getElementById("frm_field_438_container").innerHTML = numWords + ' words';
});
});
Sorry for the formatting, but I have yet to figure out how to correctly use the "code" blocks in these answers. Every once in a while I accidentally get it right.
https://paste2.org, then paste the link created. It's ugly here.
Good point! I forget about that option approximately 100% of the time.
Here is nicely formatted code - https://paste2.org/1WgX9nWc
Please login or Register to submit your answer