Disable browser autocomplete; Deny Copy and Paste

Many web forms include some fields that should force users to input their data manually in contrast of using built-in operation systems' (OS) features like "Copy and Paste" or the browsers' "autocomplete" feature.
Examples of such fields are: Email Verification fields, Password fields, Captcha fields and more.

So how do we disable the browsers' autocomplete feature just for a specific field and not entirely? And how can we deny visitors from using the OSs' built-in Copy and Paste feature?

Some may suggest using Javascript to capture the users' actions, like right-clicking the mouse or the Ctrl+C / Ctrl+V key combinations and then stopping the operation. But this is obviously not the best or simplest solution.
The solution is integrated in the input field properties itself together with some event capturing using Javascript.

In order to disabled the browsers' autocomplete, simply add the attribute to the input field. It should look something like this:

<input type="text" autocomplete="off">

And if you want to deny Copy and Paste for that field, simply add the Javascript event capturing calls oncopy, onpaste, and oncut and make them return false, like so:

<input type="text" oncopy="return false;" onpaste="return false;" oncut="return false;">

Easy, huh?

Some may take the next step and try using onselectstart to deny the input field's content selection from the user, but be warned: this only works for Internet Explorer. The rest of the above work great on all the major browsers: Internet Explorer, Mozilla Firefox, Apple Safari (on Windows OS, at least) and Google Chrome.

Comments

Thank's!! :)ByeCessione

Thank's!! :)
Bye
Cessione

Why would you disable

Why would you disable copy/paste? Makes no sense.

A few reasons

Usually this is used in registration forms when you wish to make sure the user types in his password and then types it again in another text field to verify. So, in the second text field you will need to make sure Copy&Paste is not an option so the user will have to actually re-type the same password.

So now instead of securely

So now instead of securely copying and pasting my long passwords, I have to type them, which forces me to either use shorter passwords or display my password on screen. Either way, you're opening me up to keyloggers for no good reason.

Good discussion here: http://stackoverflow.com/questions/4760132/improving-login-security-thro...

But thanks for letting me know that this behavior is javascript, so I can easily disable it.

Agree with the other

Agree with the other anonymous, don't do this for login forms.

Seriously some of you REALLY don't get this??? SHEESH!!!

Okay first off for login forms you may not disallow copy and pasting, but you might disallow auto complete for SECURITY REASONS!!! (if you don't know what auto complete is, look it up)

On a signup form you might would want copying and pasting disabled on a password confirmation field or an e-mail/username confirmation field. Why?? because people make mistakes, and on a signup form you want to make sure they are not making typos on these important fields..

and to the person who whined about having to (god forbid) REMEMBER his password, and so his alternative is to make shorter passwords (which some SECURE systems will not allow or "display my password on screen" and being (wah wah) vulnerable to key loggers here's a suggestion.. A PASSWORD SAFE PROGRAM!!!

Please help me to with this

Hello! Speedy problem that's fully off of subject matter.
Have you figured out how to make simple a website cell warm and friendly? My web page appears to be bizarre when browsing from my mobile phone.
I'm looking for a motif or plugin that might be able to take care of this challenge. If you have any suggestions, please share.
Thanks a lot.

Mobile designated design

A mobile designated website design is one solution. Others may include a single website design that is compatible both for desktop PC,tablets and mobile phones - a responsive design. Not familiar with a magic plugin or tool that would magically transfer a website to fit mobile devices with no extra work.

hi

thanks

You can use Wordpress

You can use Wordpress designed website to do the trick. Easy to setup, this would allow you to have full mobile responsive layouts. I work in a S.E.O company (web-alliance.com) and we use this technology for customers. It's easy, not expensive and gets the job done.

This is absolutely the most annoying thing,

not to mention foolish.
It FORCES people to use weak passwords by refusing them access to a secure password generator and manager, such as LastPass.
Coding for the stupidest 2% hinders all the rest of us who are not dumb.
Please stop coding annoyances, please stop telling other people how to be annoying.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Image CAPTCHA