Skip to main content
Nintex Community Menu Bar

Prevent from Navigating Away from the Form

  • September 24, 2019
  • 3 replies
  • 19 views

Forum|alt.badge.img+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

Forum|alt.badge.img+17
  • September 25, 2019

@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

 


Forum|alt.badge.img+1
  • Author
  • October 1, 2019

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;

 

 


thesturl
Forum|alt.badge.img+1
  • October 10, 2019
This is exactly what I was looking for. Thanks for posting!