0

Hello,
I want to disable tab event from input box on form
for that i tried:

<script language="JavaScript">
    // disable tab event on form
    $(window).keydown(function(event){
        if(event.keyCode == 9 ) {
            alert("tab is clicked") // it alerts but execute get vanished quickly
          event.preventDefault();
          return false;
        }
      });
</script>

and

document.querySelector('input').addEventListener('keydown', function (e) {
    if (e.which == 9) {
        e.preventDefault();
    }
});

but still it is processing on above code.

is there any ither way?

2
Contributors
1
Reply
15
Views
3 Years
Discussion Span
Last Post by AleMonteiro
0

You have to append the listener to the input:

$("input").keydown(function(event){
        if(event.keyCode == 9 ) {
          event.preventDefault();
          return false;
        }
      });
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.