Last active
January 16, 2017 02:20
-
-
Save JustinDFuller/ebef98aa6dbd0f10350dbf5db62cbce1 to your computer and use it in GitHub Desktop.
Don't allow pasting of certain items or certain inputs.
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
const stopPasting = event => { | |
const data = event.clipboardData.getData('text'); | |
if (event.target.id === 'passwordConfirmation' || data === 'theUserPassword') { | |
return event.preventDefault(); | |
} | |
// If it passes all checks you are still free to do other things, like record the pasted | |
// Data elsehwere in the app, or change the data with setData() | |
}; | |
document.addEventListener('paste', stopPasting); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment