Friday, February 23, 2018

how to prevent user to close your modal popup with ESC key?

it is very useful to have a modal to block the page content being accessed by user, when we allow user to modify the data in the Modal Popup. However, the user can close the modal by press the Escape key without clicking on the close button.

the fix is quite easy, we just have to add a new element attribute data-keyboard="false" to the DIV

here is sample code to prevent the user close the modal by pressing the escape

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false" style="overflow-y: auto;">

No comments:

Post a Comment