Header Ads

BlockCopyAndPaste Directives



BlockCopyAndPaste Directives



This will block the copy and paste functionalities in the input box. use this directive to block this functionality



Add the directives name inside the input field

<input type = "text" name="name" blockCopyPaste >


Save this directive and name it as blockCopyPaste

   @HostListener('paste'['$event']) blockPaste(event: keyboardEvent) {
        event.preventDefault();
    }

   @HostListener('copy'['$event']) blockCopy(event: keyboardEvent) {
        event.preventDefault();

    }

   @HostListener('cut'['$event']) blockCut(event: keyboardEvent) {
        event.preventDefault();

    }

Post a Comment

1 Comments