# Preventing User from Navigating Away From Form

**URL:** <https://forums.knack.com/t/preventing-user-from-navigating-away-from-form/6937>\
**Category:** Get Answers\
**Created:** [October 12, 2018, 5:21pm UTC](https://forums.knack.com/t/preventing-user-from-navigating-away-from-form/6937 "2018-10-12T17:21:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![WesleyCart03896](https://avatars.discourse-cdn.com/v4/letter/w/a183cd/32.png) [@WesleyCart03896](https://forums.knack.com/u/WesleyCart03896)\
**Post date:** [October 12, 2018, 5:21pm UTC](https://forums.knack.com/t/preventing-user-from-navigating-away-from-form/6937/1 "2018-10-12T17:21:12Z")

</div>

I have tried many different solutions using onbeforeunload() and other JS/jQuery, but the functions do not work the way I want, and I think it is because of the way that Knack loads and renders pages. It works when a user reloads a page or closes the tab or window, but I need it to work when they press back or try to navigate to a new page. Has anyone successfully done this?

I realize that I could tie my multi-step form into a logged-in user and have their data persist, but my boss is insisting on having one monolithic form with a single submit button where this is not possible without a great deal of work with the API.

Thanks

---

<div class="post-metadata">

**Author:** ![Johnny\_Appknowledged\_UK](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/johnny_appknowledged_uk/32/2898_2.png) [@Johnny\_Appknowledged\_UK](https://forums.knack.com/u/Johnny_Appknowledged_UK)\
**Post date:** [October 12, 2018, 6:16pm UTC](https://forums.knack.com/t/preventing-user-from-navigating-away-from-form/6937/2 "2018-10-12T18:16:24Z")

</div>

Hi Wesley,

Wanna see if I can help but not quite sure what the question is. As far as I can tell you want a function to run when a user hits the back button to the parent page from a form on a child page?

But what is it you are wanting to achieve. Pop me a email and ill see if I can help

[jonathan.mart.parsons@gmail.com](mailto:jonathan.mart.parsons@gmail.com)

Johnny
