Prevent from Navigating Away from the Form

  • 24 September 2019
  • 3 replies
  • 2 views

Badge +1

Hello,

 

I'm trying to add a prompt warning window in Nintex warning users of losing their form data if a user accidentally presses the back button on the browser or clicks on a side navigation bar.

 

I've found the code online using Javascript

 

window.onbeforeunload = function() {
  return "Are you sure you want to navigate away?";
}

My question is how would I incorporate this into Nintex?

 

Thank you.


3 replies

Badge +17

@Will_Iam within the Nintex form designer you can embed javascript into the form settings or on a control. I am not sure you can do that on submit, but there is an option to do that via client click.

 

4639iEB41E271A658953C.png

 

Badge +1

I figured out the solution.

Add the following to the Javascript section in form settings:

 

NWF$(document).ready(function(){  

 window.onbeforeunload = function() {
 return "Are you sure you want to navigate away?";
} });

 

 

A confirmation will pop up when you submit the form as well.  To make that an exception add the following to Client click section of the button:

 

window.onbeforeunload = null;

 

 

Badge +1
This is exactly what I was looking for. Thanks for posting!

Reply