# Reset form on back button

**URL:** https://community.gravityforms.com/t/reset-form-on-back-button/14881
**Category:** Get Help
**Tags:** conditional-logic, custom, javascript, browser-back-button, reset-form
**Created:** [April 6, 2023, 8:54pm UTC](https://community.gravityforms.com/t/reset-form-on-back-button/14881 "2023-04-06T20:54:09Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ruanna](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/ruanna/32/4958_2.png) [@Ruanna](https://community.gravityforms.com/u/Ruanna)
#### Post date: [April 6, 2023, 8:54pm UTC](https://community.gravityforms.com/t/reset-form-on-back-button/14881/1 "2023-04-06T20:54:09Z")

</div>

I have a form with a fair amount of JS. Two fields are shown initially, and then depending on what is chosen, other fields appear. (It was too complex to use conditional fields, so it’s all in JS.)

If the user submits the form without filling out a required field, I keep the values and re-show the appropriate fields. Otherwise, they’re hidden on load.

It looks like people can submit the form and then hit the back button though. It keeps the values loaded, they can change any and then resubmit.

Is there a way to clear the page if the user uses the back button?

Thank you!

---

<div class="post-metadata">

### Author: ![dwiseman57](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/dwiseman57/32/2149_2.png) [@dwiseman57](https://community.gravityforms.com/u/dwiseman57)
#### Post date: [April 12, 2023, 7:46pm UTC](https://community.gravityforms.com/t/reset-form-on-back-button/14881/2 "2023-04-12T19:46:03Z")

</div>

I would also like to know the answer to this. My submit button doesnt work if the user goes back and the form is pre-filled because of all the confirmation logic. Would be better if the forms reset on “back”…

---

<div class="post-metadata">

### Author: ![Ruanna](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/ruanna/32/4958_2.png) [@Ruanna](https://community.gravityforms.com/u/Ruanna)
#### Post date: [April 18, 2023, 9:08pm UTC](https://community.gravityforms.com/t/reset-form-on-back-button/14881/3 "2023-04-18T21:08:55Z")

</div>

We’re trying this and it seems to work at least in Chrome:

```auto
if ( performance.navigation.type == 2 ) {
   location.reload( true );
}

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)
#### Post date: [May 18, 2023, 9:09pm UTC](https://community.gravityforms.com/t/reset-form-on-back-button/14881/4 "2023-05-18T21:09:31Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
