Lightbox Capture Lock

Hello,
I am trying to create a lead capture lightbox that does not close until the user enters their email and hit enter.

Scenario:
User comes to a page to watch a video. A lightbox is loaded on load and the user has to put in their email before they can close the lightbox and access the website. I currently have the lightbox working but for some reason, it reopens after submitting the email.

Please help

i currently have this code on my home page.
https://enibeatsworldwide.wixsite.com/28days

import wixWindow from 'wix-window'; $w.onReady(function () {  neverExit();   }); function neverExit() { wixWindow.openLightbox('lightbox1') .then((data) => { if (!data || !data.forceExit) { neverExit(); } }); }

Hi yussuf,

first of all i suggest you to click on the lightbox overlay in the editor and then click on overlay settings->turn off the option -
clicking closes lightbox.

then you can use this code in lightbox-page

import wixWindow from ‘wix-window’;
$w.onReady( function () {
//TODO: write your page related code here…
});
export function submitButton_click(event) {
//Add your code for this event here:
const email = $w(‘#emailInput’).value;
if (email===“”){
//if the email input is empty we won’t close our lightbox
return ;
}
else {
//do what you want with the email input
wixWindow.lightbox.close(email);
}
}

I have a similar question. If I wanted to lock the screen like restrict access but on another screen like an admin screen with a button it can be turned off and turned back on just by the click of a button or switch? Is that possible to do?