When the user pastes the elements' text, the onpaste attribute triggers in HTML.
Example
You can try to run the following code to implement the pastes attribute −
<!DOCTYPE html>
<html>
<body>
<input type = "text" onpaste = "display()" value = "Paste text here">
<h2 id = "test">Try to paste any text.</h2>
<script>
function display() {
document.getElementById("test").innerHTML = "Your pasted text worked!";
}
</script>
</body>
</html>