2

In either Javascript or HTML, is there a way to disable all user input except for a selection of keyboard presses? For example, if I trigger an error that shows a popup error message, is there a way to block any other user input into the DOM in the backround until the user has dismissed the popup using the Enter key?

Thank you all in advance!

Codebling
  • 10,764
  • 2
  • 38
  • 66
Mitch
  • 53
  • 6

1 Answers1

2

If I understand you correctly, you might want to disable keyboard and mouse activity beyond the modal when opening like with this related question. Here is the summary of the options included:

If you opening the modal by js use:

$('#myModal').modal({backdrop: 'static', keyboard: false})  

If you are using data attributes, use:

 <button data-target="#myModal" data-toggle="modal" data-backdrop="static" data-keyboard="false">
    Launch demo modal
 </button>`
MUlferts
  • 1,310
  • 2
  • 16
  • 30
  • Thank you @MUlferts! The popup is a modal from the Noty library in awesome-vue using Vue.js. In the Noty library there is an option to make the popup a modal in the opts, do you know if there's a way to grab whichever modal is in focus in the DOM? – Mitch Apr 14 '20 at 15:19
  • It looks like vue.js has a little different selector for opening a modal in javascript than with the jquery example above. [See this question](https://stackoverflow.com/questions/50428046/vue-js-open-modal-by-click-of-a-button) for an example of how to open from vue.js. You would have the DOM element in a variable if you opened this way instead of through an HTML button using data-attributes. – MUlferts Apr 14 '20 at 15:35