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) {
e.preventDefault();
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) {
e.preventDefault();
});

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

Leave a Reply

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

%d bloggers like this: