Hello,
I have a question response option that allows text entry. I want to limit the range of the number so that the number entered is less than 20.
I found this discussion which included the following javascript.
https://www.qualtrics.com/community/discussion/1125/how-to-set-a-field-to-number-only
jQuery("#"+this.questionId+" .InputText").attr({'type':'number','min':'0'});
I thought that I could modify line to the following, but it did not work. It does limit the value to a number but I can enter a number greater than 20.
jQuery("#"+this.questionId+" .InputText").attr({'type':'number','max':'20'});
Is there away to limit the response to a number less than 20?
Thank you.
Page 1 / 1
Add this to your JS, it will limit responses to max 20.
Qualtrics.SurveyEngine.addOnReady(function () {
this
.questionContainer
.querySelector("#" + this.questionId + " .InputText")
.oninput = function (ip) {
if(ip.target.value > 20) {
ip.target.value = 20
}
};
});
Just make sure you mention the max 20 somewhere, otherwise your respondents will be confused.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.