I added some helpful JavaScript code found in this community to an essay text box which allows me to create a 250 word limit. Works perfectly except I cannot copy text from a Word document into the essay box. Without the code, I easily can. Note that I have tried to copy and paste a word count way below the max. Code used is below. Thank you for any feedback!
-----------------------------------------------------------------------------------------------
Qualtrics.SurveyEngine.addOnReady(function()
{
var that=this.questionId;
jQuery("<p id='count'>Words remaining: 250</p>").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(/^c\\s,.;]+/, "").replace(/a\\s,.;]+$/, "").split(/l\\s,.;]+/).length;
jQuery("#count").text("Words remaining: "+(250-parseInt(numOfWords)));
if( numOfWords > 250 ){
event.preventDefault();
}
});
});