Get cool snippets on php, css, jQuery, Magento and wordpress

Disable paste option in textbox

With the help of jQuery event.preventDefault() method we can disable paste in textbox.

It can be used in the situation where user enters his confirmation email id in registration form.

$('#confirm-email').bind("paste",function(e) {
alert('You cannot pase text into this textbox');

Some other events:

cut,copy,contextmenu(disables right click)

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

It will prevent all the four actions ie., We cannot perform those 4 actions(cut, copy, contextmenu and paste) in ‘confirm-email’ field.

Reference : How can I disable Ctrl+V (Paste) option using jQuery in one of my input text fields

karthi s

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: