Prevent users from navigating away from form

  • bishopfarm
    Asked on March 29, 2017 at 6:39 PM

    Is there a way for me to block users from navigating away from the form? On a mac for example it is easy to do a two finger swipe to the left and go back to the previous page (losing all the info entered on the form). This is normally done through a beforeunload. I would rather have this as a form option other than having to tweak with custom javascript myself. My understanding is that tweaking the JS manually does not work nicely if I them modify the form template somehow.

  • jonathan
    Replied on March 29, 2017 at 9:32 PM

    If your form was published on a website page, you will need to add your own custom javascript on your website that will do this function.

    But if you will only be using your form URL, there is no way to achieve this. Because it requires injection of javascript code that will do this function.

    You can apply it using your form source code, but it will still require you to have your own hosted page if you will use the form source code.

    I found on the internet such javascript code function that do such action. Check it here 

    http://stackoverflow.com/questions/821011/how-do-you-prevent-a-webpage-from-navigating-away-in-javascript

    Let us know how we can be of further assistance.

     

     

     

     

  • bishopfarm
    Replied on March 30, 2017 at 2:04 PM

    Yes you basically posted the same link I did. Would it be possible to add this feature to the form? Seems like a basic thing to have...

  • Support_Management Jotform Support
    Replied on March 30, 2017 at 3:44 PM

    As of now, there's no way to have this feature added within the Form Builder. The only way around this is to go with my colleague's suggestions:

    1. Grab the Full Source code of your form

    2. Use it to embed the form on your website

    3. Then use the script from the Stackoverflow discussions cited (by you or by my colleague)

    In case you need more help, just let us know.