Solved

How to disable paste into a lead form

  • 28 September 2023
  • 2 replies
  • 27 views

Badge

Related to my other post about spam leads…

 

I know there’s HTML which can be used with a Form input to disable paste. While I know some users may find it frustrating, I know it will really frustrate the people who are entering spam leads. They are not bots.

Anyone have any tips on how to do this?  This is what I have found online, just can’t see how to implement it in my form.

<input type="text" onpaste="return false;" ondrop="return false;" autocomplete="off" />

icon

Best answer by go101 1 October 2023, 19:08

View original

2 replies

Badge

I figured this out. It was easier using a Javascript code.

 

This blocks right click and copy/paste.

 

<script>

document.addEventListener("contextmenu", function(event){

event.preventDefault();

alert('Right Click is Disabled');    

}, false);

</script>

 

<script>

document.querySelectorAll("p").forEach(elem => {

    elem.addEventListener("copy", event => {

      event.preventDefault();

    });

    elem.addEventListener("dragstart", event => {

      event.preventDefault();

    });

  });

 

  document.querySelectorAll("input").forEach(elem => {

    elem.addEventListener("copy", event => {

      event.preventDefault();

    });

    elem.addEventListener("paste", event => {

      event.preventDefault();

    });

    elem.addEventListener("drop", event => {

      event.preventDefault();

    });

  });

</script>

Userlevel 4
Badge +1

Awesome @go101 🙌🏻 thanks for sharing your solution. It’s always cool when the person looking for help answers their own question. 😂

Reply