Last active
August 31, 2021 07:36
-
-
Save Mikescops/9a582d1b39b722dc3f19c952441822e4 to your computer and use it in GitHub Desktop.
Prevent pasting in a field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Experiment prevent pasting</title> | |
</head> | |
<body> | |
<h2>Login to your account</h2> | |
<p for="login">Login</p> | |
<input type="text" name="login" id="login" value="[email protected]" /> | |
<p for="login">Password</p> | |
<input type="password" name="password" id="password" /> | |
<script> | |
document.getElementById('password').addEventListener('paste', (event) => { | |
if (!confirm('You are pasting on a potential phishing website, continue?')) { | |
event.preventDefault(); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment