What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    How to create a textbox that prevent copy and paste?

    Asked by Apriyanto Salim on August 09, 2011 at 06:54 AM

    I want to create a textbox that the users can't copy and paste from the word processor. What can I do to get this feature?

    textbox javascript
  • Profile Image

    Answered by allanftd on August 09, 2011 at 07:43 AM

    Hi Apriyanto,

    Please try adding these attributes into your textbox's <input> tag:

    onCopy=”return false” onDrag=”return false” onDrop=”return false” onPaste=”return false” autocomplete=off

    example:

    <INPUT size=12 name=”Sample Name” maxlength=12 onCopy=”return false” onDrag=”return false” onDrop=”return false” onPaste=”return false” autocomplete=off>

    You need to get the full source code of your form in order to accomplish this. 

    Please let us know if you have any ther questions or concerns. Thank you for using JotForm!

    JOTFORM SUPPORT


  • Profile Image

    Answered by apri_07 on August 12, 2011 at 05:23 AM

    I've tried to change the source code as it's written, but the copy and paste feature is still enabled.

  • Profile Image
    JotForm Support

    Answered by NeilVicente on August 12, 2011 at 07:18 AM

    Hi,

    To answer in behalf of our colleague, here's something I stumbled upon while searching the net:

    Paste the code below anywhere in your page's source code

    <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;"/>

     

    Hope this works for you. Thanks!


    Neil

     

    Source: http://stackoverflow.com/questions/1226574/disable-copy-paste-into-html-form-using-javascript

  • Profile Image

    Answered by $(document).ready(function() { $(#text1).bind("cut copy paste", function(e) { e.preventDefault(); alert("You cannot paste text in on May 06, 2015 at 09:34 AM
    <script type="text/javascript"> $(document).ready(function() { $('#text1').bind("cut copy paste", function(e) { e.preventDefault(); alert("You cannot paste text into this textbox!"); $('#text1').bind("contextmenu", function(e) { e.preventDefault(); }); }); }); </script>