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

Comments

Popular posts from this blog

Send email from xampp localhost

Modify item price in cart after placing order using sales_quote_add_item

Convert long url to short url using tinyurl api