0

Im using Gravity forms on Wordpress. We have a text area that we have disabled cut, copy, paste and drop using Javascript.

We are using the following:

<script type="text/javascript">
$(function () {
    var controls = $(".disable");
    controls.bind("paste", function () {
        return false;
    });
    controls.bind("drop", function () {
        return false;
    });
    controls.bind("cut", function () {
        return false;
    });
    controls.bind("copy", function () {
        return false;
    });
});
$('textarea').on('paste', function () {
 var element = this;
 setTimeout(function () {
 $(".paste-alert").append("<b>Copy and paste detected:</b> Please take time to write a unique description for your listing. This will ensure your advert will get found in the search engines and help keep Local Business a high authority, free directory. ");
 }, 100);
 });
 </script>

and adding a "disable" class to the textarea.

We also have a separate element:

<p class="paste-alert"></p>

When a user attempts to copy and paste in to the text area we want the text:

"Please don't copy and paste"

To appear in the .paste-alert element

Can anyone help, this is driving me crazy?!

Alan Carr
  • 322
  • 2
  • 9
  • 25

1 Answers1

0

You can archieve this with:

$('input').on('paste', function () {
  var element = this;
  setTimeout(function () {
    $(".paste-alert").append("<b>Copy and paste detected:</b> Please take time to write a unique description for your listing. This will ensure your advert will get found in the search engines and help keep Rate Local a high authority, free directory. ");
  }, 100);
});

Fiddle: http://jsfiddle.net/me5dvwqL/3/

Source (best voted answer): Catch paste input

EDIT:

Final fiddle after chat: http://jsfiddle.net/n4hw4cer/4/

Community
  • 1
  • 1