How to Disable Right Click Using jQuery?

When we build a web application, a few times we do not want the users to use the right button of the mouse. It's possible to either completely or partially disable right-click context sensitive menus or replace them with a custom dialog which is applicable to the application. The contextmenu event is sent to an element when the right button of the mouse is clicked on it, but before the context menu is displayed. Syntax
$('selector').contextmenu(function() { return false; });

How to disable right click menu in html page using jquery?

To disable right click menu on the page completely , use the following:
$(document).contextmenu(function() { return false; });
run this source code Browser View

Try right-click on the page

Full Source
<!DOCTYPE html> <html lang="en"> <head> <title>How to prevent Right Click option using jquery</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(document).contextmenu(function() { return false; }); }); </script> </head> <body> <p>Try right-click on the page</p> <input type="text" class="myTextBox1" /> </body> </html>

How to disable mouse right click on textbox using jQuery?

$(".myTextBox1").on("contextmenu",function(e){ return false; });
run this source code Browser View

Try right-click on the textbox

Full Source
<!DOCTYPE html> <html lang="en"> <head> <title>How to disabled textbox Right Click</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".myTextBox1").on("contextmenu",function(e){ return false; }); }); </script> </head> <body> <p>Try right-click on the textbox</p> <input type="text" class="myTextBox1" /> </body> </html>