0

is there a possibility that you can restrict a user from right clicking a disabled button? i am restricting a user for it will not be able to inspect element and remove the disabled attribute in a button. in MOZILLA FIREFOX

$('input:disabled').bind('contextmenu', function(e) {
    return false
});

this code only works on enabled button

Raymond
  • 137
  • 1
  • 12
  • you cant right click a disabled button – guradio Sep 15 '17 at 02:36
  • you can right click it and inspect it in the browser. in mozilla firefox – Raymond Sep 15 '17 at 02:38
  • why don't just remove it? the best prevention for the user to fire the event is do a validation in the server side, is not best experience to restrict right click, beside right click, `f12` key stroke also your main concern if you really want to remove right click – Se0ng11 Sep 15 '17 at 02:43
  • Possible duplicate of [How do I disable right click on my web page?](https://stackoverflow.com/questions/737022/how-do-i-disable-right-click-on-my-web-page) – guradio Sep 15 '17 at 02:45
  • If someone intends to remove the disabled attribute, disabling right click for the button will not change anything. – josephting Sep 15 '17 at 02:48
  • maybe i look for different solution and approach then. thanks for the answers – Raymond Sep 15 '17 at 02:51

1 Answers1

1

It may be better to restrict right-clicking on the whole page itself since even if the user cannot right-click on the disabled button, the user can still right-click on any other element that is not disabled and look up your disabled button from there and remove the disabled attribute.

Arkhaine
  • 131
  • 4
  • yah i tried it also. my main concern is on firefox it works in google chrome – Raymond Sep 15 '17 at 02:41
  • 1
    If you are using any server side scripting like PHP, then might be better to have it draw the button instead so that if its supposed to be disabled then the button isn't even in the markup at all. – Arkhaine Sep 15 '17 at 02:53
  • This is the correct solution. It's a stall at best, since F12 will allow access anyway, but if you want to prevent the "basic" right click, you have to disable it everywhere since clicking right beside the button would give you access to the button anyway. – Jerod Venema Sep 15 '17 at 03:16