Skip to content

Commit fb3caeb

Browse files
authored
Preventing paste into an input field
1 parent 5d87a65 commit fb3caeb

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
|28 | [Notify when element size is changed](#Notify-when-element-size-is-changed)|
3535
|29 | [Detect if Browser Tab is in the view](#Detect-if-Browser-Tab-is-in-the-view)|
3636
|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)|
3838

3939

4040

@@ -643,6 +643,20 @@ console.log(instance.getPrivateMessage()); //=> Come and learn Js with us
643643
```
644644
645645
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+
646660
647661
648662

0 commit comments

Comments
 (0)