In the legacy survey taking experience, I’m able to use the code here:
However, this code does not work in the new survey taking experience (NSTB). Can anyone provide code that I can use to do the same thing in NSTB?
In the legacy survey taking experience, I’m able to use the code here:
However, this code does not work in the new survey taking experience (NSTB). Can anyone provide code that I can use to do the same thing in NSTB?
Best answer by vgayraud
Hi,
Here’s
Qualtrics.SurveyEngine.addOnload(function () {
var limits = [50, 0, 200]; // one per input, in order. 0 means no limit.
var inputs = document.querySelectorAll("#question-" + this.questionId + " .choice-te-wrapper .text-input");
inputs.forEach(function (input, i) {
var maxChars = limits[i] || 0;
if (maxChars === 0) return;
input.placeholder = maxChars + " character limit.";
var display = document.createElement("div");
display.style.cssText = "visibility:hidden; padding-top:4px;";
display.innerHTML = "Characters remaining: <span class='charCount'>" + maxChars + "</span>";
input.closest(".choice-te-wrapper").insertAdjacentElement("afterend", display);
input.addEventListener("input", function () {
var remaining = maxChars - input.value.length;
if (remaining < 0) {
input.value = input.value.substring(0, maxChars);
remaining = 0;
}
display.style.visibility = input.value.length > 0 ? "visible" : "hidden";
display.querySelector(".charCount").textContent = remaining;
});
});
});
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.