Home > Blockchain >  How to confirm from user if he wants to leave the page while filling form?
How to confirm from user if he wants to leave the page while filling form?

Time:11-03

I am creating a form where user can fill data. Based upon the user's input and selected options I'm showing the next data to fill using js which works totally fine.

Now what I want is if the user presses the back or exit button accidentally. I want to confirm with the user if he really wants to exit from the current page.

CodePudding user response:

Try using a confirm dialog to get user confirmation when the beforeUnload event is fired, which gets fired when the document is about to be unloaded from the DOM, which includes browser moving to another page or exiting the website.

  • Related