Oracle Apex: Disable Escape Key (ESC) to Prevent Close Dialog

In Oracle Apex, you have created a modal dialog page and you want to disable the escape key to prevent close dialog window. To achieve this, follow these simple steps:

Disable ESC Key to Prevent Close Dialog

Open your dialog page in Oracle Apex. Then right side in the property palette, scroll down to the Dialog section and add the following code to the Attribute property:


Below is the screenshot for your reference:

Prevent close modal dialog on ESC key.

Now save the changes and run its parent page to test and you will see, on Escape key press the dialog will not close.

But what if the user will close the dialog from the title bar (X) close button? Maybe you want the user to close the dialog via close/cancel button only, because you may have written some code on it. To disable the title bar close (X) button, follow these steps:

Hide Dialog Window Title Bar Close (X) Button

Open the parent page from where you are opening the dialog page and add the following CSS code in the Inline CSS property section:

.no-close .ui-dialog-titlebar-close {
   display: none;

Save the changes to the parent page.

Now open your dialog page and in the Dialog property section add the no-close class in the CSS Classes property. You will find this property below the Attribute property, you can see it in the above image.

Save the changes and to test it at runtime, refresh the parent page first, and then open the dialog, you will not see the title bar close (X) button, as shown in the below image:

Hiding dialog window title bar close button.

Now the user has to press the Cancel or Apply Changes button to close the dialog. The user will not be able to close using the Escape key or via the title bar close button.

Related Tutorials:

Written by Vinish Kapoor

An Oracle Apex Consultant, Oracle ACE, and founder of and a question and answer forum for developers.


Newest Most Voted
Inline Feedbacks
View all comments