1

I have an application built using angularjs. On one page i have a modal pop up with form elements(elements are not within a form tag consists of buttons and input tags). When the bootstrap modal opens the focus is on the first input element. Is there a way by which i can contain the tab key press event only to the bootstrap modal pop up, cause when i press tab a few times more the control goes to the browser address bar and i can edit the URL. I do not want this behavior, the tab press should only allow users to have focus on the pop up window.

1 Answers1

1

I think you will find your answer here

$('#confirmCopy :input:first').focus();

$('#confirmCopy :input:last').on('keydown', function (e) { 
    if ($("this:focus") && (e.which == 9)) {
        e.preventDefault();
        $('#confirmCopy :input:first').focus();
    }
});

Keep tabbing within modal pane only

Community
  • 1
  • 1
Wcan
  • 840
  • 1
  • 10
  • 31