-1

I have my input Textbox like below. User should not be allowed to perform copy paste in the Textbox. But somehow my code is not working. Is there any other approach?

<input type="text" class="form-control"  id="startTextbox1" appOnlynumber onkeypress='validate(event)' onCopy="return false" onDrag="return false" onDrop="return false" onPaste="return false" formControlName="startTextbox1">

I have also written custom directive like it specified in below link but its not working.

https://stackblitz.com/edit/angular-u4jcam?file=app%2Fapp.component.html

Any suggestions please?

isherwood
  • 52,576
  • 15
  • 105
  • 143
user1989
  • 25
  • 6

2 Answers2

0

Not sure this is what you are going for, but perhaps this prior question gives you some place to start:

Disable pasting text into HTML form

John Harper
  • 135
  • 1
  • 7
0

I know you can do this with JS / jQuery

$(document).ready(function(){
   $('#startTextbox1').on("cut copy paste",function(e) {
      e.preventDefault();
   });
});

Hope that can help

Brian Wiltshire
  • 447
  • 4
  • 15