I tried using the following javascript, to only allow certain responses to a text entry question. However, it is not working. Any suggestions?
Thanks a lot in advance.
1Qualtrics.SurveyEngine.addOnPageSubmit(function() {2 // Target the text entry question by its QuestionID3 var questionId = 'QID1';45 // Specify the pre-specified options6 var validOptions = ['Option 1', 'Option 2', 'Option 3'];78 // Get the entered value from the text entry question9 var enteredValue = this.getChoiceValue(questionId);1011 // Check if the entered value is not one of the valid options12 if (!validOptions.includes(enteredValue)) {13 this.setChoiceError(questionId, 'Please enter a valid option.');14 this.disableNextButton(); // Disable the next button15 } else {16 this.clearChoiceError(questionId);17 this.enableNextButton(); // Enable the next button18 }19});20
