Hello, I found the following code that limits words and displays a word count for a text entry question and is nearly ideal for what I need, however it does not enable individuals to paste text into a box. Can someone assist with changing the code to allow for pasted text?
var that=this.questionId;
jQuery("
Words remaining: 100
").insertAfter("#"+that +" .QuestionText");var numOfWords = 0;
jQuery("#"+that +" .InputText").on("cut copy paste",function(e) {
e.preventDefault();
});
jQuery("#"+that +" .InputText").keypress(function(){
numOfWords =jQuery("#"+that +" .InputText").val().replace(/^[\\s,.;]+/, "").replace(/[\\s,.;]+$/, "").split(/[\\s,.;]+/).length;
jQuery("#count01").text("Words remaining: "+(100-parseInt(numOfWords)));
if( numOfWords > 100 ){
event.preventDefault();
}
});