|
34 | 34 | |28 | [Notify when element size is changed](#Notify-when-element-size-is-changed)|
|
35 | 35 | |29 | [Detect if Browser Tab is in the view](#Detect-if-Browser-Tab-is-in-the-view)|
|
36 | 36 | |30 | [Private class methods and fields](#Private-class-methods-and-fields)|
|
37 | | - |
| 37 | +|31 |[Preventing paste into an input field](#Preventing-paste-into-an-input-field)| |
38 | 38 |
|
39 | 39 |
|
40 | 40 |
|
@@ -643,6 +643,20 @@ console.log(instance.getPrivateMessage()); //=> Come and learn Js with us
|
643 | 643 | ```
|
644 | 644 |
|
645 | 645 |
|
| 646 | +**[⬆ Back to Top](#table-of-contents)** |
| 647 | +### Preventing paste into an input field |
| 648 | +see our codepen: https://codepen.io/JSsnippets/pen/qBbyMoJ |
| 649 | + |
| 650 | +```javascript |
| 651 | + |
| 652 | +const pasteBox = document.getElementById("paste-no-event"); |
| 653 | +pasteBox.onpaste = (e) => { |
| 654 | + e.preventDefault(); |
| 655 | + return false; |
| 656 | +}; |
| 657 | + |
| 658 | +``` |
| 659 | + |
646 | 660 |
|
647 | 661 |
|
648 | 662 |
|
0 commit comments