Mr.Cocococo Mr.Cocococo - 1 year ago 127
Javascript Question

Disable Copy or Paste action for text box?

I have two textboxes, and I want to prevent user from copying the value from the first (email) textbox and pasting it in the second (confirmEmail) textbox.

Email: <input type="textbox" id="email"><br/>
Confirm Email: <input type="textbox" id="confirmEmail">

I have two solution in my mind:

  1. Prevent copy action from the email textbox, or

  2. Prevent paste action from the confirmEmail textbox.

Any idea about how to do it?

Answer Source

Check this fiddle fiddle

 $('#email').bind("cut copy paste",function(e) {

You need to bind What should be done on cut,copy paste.You prevent default behavior of the action. You can find detailed explanation here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download