Prevent users from pasting text into text entry fields within a SIDE BY SIDE question format | XM Community
Skip to main content

I would like to prevent users from pasting text into text entry fields within a SIDE BY SIDE question format. So far, I haven't been able to find a solution that works.

We are currently using the following JavaScript code:

jQuery("#"+this.questionId+" .InputText:eq(0)").on("cut copy paste",function(e) {

   e.preventDefault();

  });

This code successfully prevents pasting when applied to text box questions. However, it does not seem to work when used in the SIDE BY SIDE question format.

Could you please let me know if there is a specific way to disable pasting in this type of question? Any advice or guidance would be greatly appreciated.

 

@Oreg.students Add this JavaScript to the question

Qualtrics.SurveyEngine.addOnload(function() {
let textInputs = this.getQuestionContainer().querySelectorAll('inputttype="text"]');

textInputs.forEach(input => {
input.addEventListener('paste', function(e) {
e.preventDefault();
});
});
});

Hope it helps


Thank you for your help and for taking the time to respond. I will try out your suggestion.


I tried implementing it, but unfortunately, it didn't work as expected. The code only prevents pasting in one of the text entry cells within the SIDE BY SIDE question, but it doesn't affect the other cells.

Ideally, I would like the code to prevent pasting in all the text entry cells within the SIDE BY SIDE question format. Do you have any other suggestions or alternative solutions that could address this issue?

Thank you again for your assistance!


@Oreg.students That shouldn't happened, because the code specifically applying rule to all of the element that have 'inputptype="text"]'

Can you show me what’s your question looks like and which box got affected and which doesn’t


Leave a Reply