How to disable copy and paste on half a page of a survey, but enable for the rest of the page? | Experience Community
Skip to main content
Question

How to disable copy and paste on half a page of a survey, but enable for the rest of the page?

  • Jan 7, 2021 2:15 AM UTC
  • 5 replies
  • 458 views

Hi there. I'm trying to disable copy and paste on my one section of my descriptive text in my survey, but enable it in another. In other words, I have two questions (both simple descriptive texts) in one block, I want one to disable copy/paste, and another to enable.
I've inserted the following code to disable copy/paste (which worked); however, it disabled copy/paste for the entire page (which is not what I wanted):

  



Any help would be much appreciated .

5 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • Jan 7, 2021 4:48 AM UTC

Remove all this CSS and just add the following code to the JS of the question on which you want to disable copy/paste:
Qualtrics.SurveyEngine.addOnReady(function(){
el = document.querySelector("#QR\\\\~"+this.questionId);
el.onpaste = function(){return false};
el.oncopy = function(){return false};
el.oncut = function(){return false};
});


  • Author
  • Jan 7, 2021 3:13 PM UTC

Thank you Ahmed. Unfortunately the code didn't seem to work - I'm still able to select the text.


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • Jan 7, 2021 3:17 PM UTC

but can you copy it?


  • Author
  • Jan 7, 2021 3:21 PM UTC

Yes it still copies


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • Jan 7, 2021 5:36 PM UTC

Please take a look at this demo. You can choose the relevant code that you want.