Execute a JavaScript when pasting some text in an <input> element:
<!DOCTYPE html> <html> <body> <input type="text" onpaste="myFunction()" value="Try to paste something in here" size="40"> <p id="demo"></p> <script> function myFunction() {//from w ww .j av a 2s.co m document.getElementById("demo").innerHTML = "You pasted text!"; } </script> </body> </html>
The onpaste event occurs when the user pastes some content in an element.
The onpaste event is mostly used on <input> elements with type="text".
Bubbles: | Yes |
---|---|
Cancelable: | Yes |
Event type: | ClipboardEvent |
Supported HTML tags: | All HTML elements |