// Change counter text color to red if the maximum length is reached if (currentLength === maxLength) { counter.style.color = "red"; } else { counter.style.color = "grey"; } }
// Update counter on input and manage text length textarea.addEventListener("input", updateCounter);
// Mark that the listener has been added textarea.dataset.listenerAdded = "true";
// Initial counter update updateCounter(); } });
Qualtrics.SurveyEngine.addOnUnload(function() { /*Place your JavaScript here to run when the page is unloaded*/
});
In addition to your requirements, I also changed the text color of the “300 / 300 characters” to red once the 300 limit is reached. If you do not want that, just comment this line: