Feature Request: Ability to prevent copying the text from the form.

  • mtscholarships20
    Asked on June 15, 2024 at 1:27 AM

    I am going to take an examination using jotform form. I am afraid if student copy the text and use chatgpt to solve the problem. That's why I want to prevent copying the text or selecting the text in the form. Is it possible?

  • Waqas JotForm Support
    Replied on June 15, 2024 at 1:46 AM

    Hi Michael,

    Thanks for reaching out to Jotform Support. I understand what you’d like to do, but I’ll need a bit of time to work out a solution. I’ll get back to you shortly.

    Thanks for your patience, we appreciate it.


  • Waqas JotForm Support
    Replied on June 15, 2024 at 2:13 AM

    Hi Michael,

    Unfortunately, the feature you're looking for isn't available at Jotform right now. We've gone ahead and escalated your request to our developers, but when or if it's developed depends on their workload, how viable it is, and how many other users also request it. If there are any updates, we’ll circle back to this thread and let you know.

    As a workaround, the copy option could only be achieved if the form is embedded into a web page with complete source code and adds additional code that will prevent copy-paste.

    <script type="text/javascript">
    (function () {
       var onload = window.onload;
      window.onload = function () {
           if (typeof onload == "function") {
               onload.apply(this, arguments);
           }
           var fields = [];
           var inputs = document.getElementsByTagName("input");
           var textareas = document.getElementsByTagName("textarea");
           for (var i = 0; i < inputs.length; i++) {
               fields.push(inputs[i]);
           }
           for (var i = 0; i < textareas.length; i++) {
               fields.push(textareas[i]);
           }
           for (var i = 0; i < fields.length; i++) {
               var field = fields[i];
               if (typeof field.onpaste != "function" && !!field.getAttribute("onpaste")) {
                   field.onpaste = eval("(function () { " + field.getAttribute("onpaste") + " })");
               }
               if (typeof field.onpaste == "function") {
                   var oninput = field.oninput;
                   field.oninput = function () {
                       if (typeof oninput == "function") {
                          oninput.apply(this, arguments);
                       }
                      if (typeof this.previousValue == "undefined") {
                           this.previousValue = this.value;
                       }
                       var pasted = (Math.abs(this.previousValue.length - this.value.length) > 1 && this.value != "");
                       if (pasted && !this.onpaste.apply(this, arguments)) {
                           this.value = this.previousValue;
                      }
                       this.previousValue = this.value;
                   };
                   if (field.addEventListener) {

                       field.addEventListener("input", field.oninput, false);

                   } else if (field.attachEvent) {

                       field.attachEvent("oninput", field.oninput);

                   }

               }

           }

       }

    })();

    </script>

    Insert onpaste="return false;" in every input tag in your form's code. 

    For example:

    <textarea id="input_12" class="form-textarea" name="q12_test" cols="40" rows="6" onpaste="return false;"></textarea>

    <input type="text" id="input_9" name="captcha" style="width:130px;" onpaste="return false;"/>

    To disable text selection (highlighting), use the following code:

    Class-name{

    -webkit-user-select: none;

    -webkit-touch-callout: none;

    -moz-user-select: none;

    -ms-user-select: none;

    user-select: none;

    }

    Give it a try and reach out again if you have any other questions.

 
Your Answer