/    Sign up×
Community /Pin to ProfileBookmark

no copy or paste

i have a form and i have a filed named [B]password[/B] and its id= password
and the other one is [B]verify password[/B]

i want to make a function so that the user cant make (copy / paste ) or (ctrl+c , ctrl+x / ctrl+v)
because many users on password field can try to copy the password and in the verify password filed they paste it again

i want to disable copy and paste in these 2 fields only.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@rnd_meOct 07.2009 — that sound incredibly annoying from a user perspective, why would you want to do that?

would you accept the forms from users without javascript? if so, then it's not only annoying, it's unfair and arbitrary.


just in case you have a good reason, here is some code:


[CODE]
<form action= "" method="POST" >
p1<input type='password' onselect="this.blur()" oncopy="this.value=''; return false;" oncontextmenu="return false;" /> <br />
p2<input type='password' onpaste="var that=this; setTimeout(function(){that.value=''}, 50)" />
</form>
[/CODE]


there might be some scenarios where this won't work, and it doesn't block context menus on safari or opera...

but hey: it's a start, and it reveals your intentions to the user.

but again, if i were stuck in some situation where i had to use an on-screen keyboard to fill out our form,

and you pulled this out on me, i would probably leave the site instead of retyping something i already finished...

(ok, in honesty, i might 'inspect element' and copy the value there, but most people wouldn't)
Copy linkTweet thisAlerts:
@Declan1991Oct 07.2009 — If the type is password, you can't copy and paste it anyway. They will have to type it in a box where they can see where they are typing first to copy and paste it, so they will see if they have mistakes.
Copy linkTweet thisAlerts:
@rnd_meOct 07.2009 — If the type is password, you can't copy and paste it anyway. They will have to type it in a box where they can see where they are typing first to copy and paste it, so they will see if they have mistakes.[/QUOTE]

well, kinda.

at least Firefox3 allows cut and paste on passwords, BUT the value copied/pasted is comprised of repeating "&#9679;" chars, so to the user it looks like it worked, and they have no way of telling it didn't until submit.

preventing a cut/paste would avoid that confusion.
×

Success!

Help @john_zakaria spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...