Execute a JavaScript when pasting some text in an <input> element: - Javascript DOM Event

Javascript examples for DOM Event:onpaste

Description

Execute a JavaScript when pasting some text in an <input> element:

Demo Code

ResultView the demo in separate window

<!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() {// w w  w .  ja  va 2s . c om
    document.getElementById("demo").innerHTML = "You pasted text!";
}
</script>

</body>
</html>

Related Tutorials