I've noticed some sites will prevent users from pasting data – anything from passwords to usernames/emails to everything. Without discussing the practice and rational/reasons for/against it, what is the technical means by which a website prevents me from pasting data into a text entry field?
For example, this site does not allow pasting into the "Retype Email Address" field. How? It's my guess that there are various ways to implement this behavior?
I'm using Firefox 62.0.2 on OS X 10.11.6.
Best Answer
Answer: JavaScript
Look at the source code of the page you link to.
It has
SFDOMEvent.preventDefault(event);
bound to theonpaste
event of the input element.preventDefault
will abort the action being taken by preventing the default behaviour - the paste. Other sites will use variations of this.