Skip to content

Instantly share code, notes, and snippets.

@JustinDFuller
Last active January 16, 2017 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JustinDFuller/ebef98aa6dbd0f10350dbf5db62cbce1 to your computer and use it in GitHub Desktop.
Save JustinDFuller/ebef98aa6dbd0f10350dbf5db62cbce1 to your computer and use it in GitHub Desktop.
Don't allow pasting of certain items or certain inputs.
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