I have a page with a form at the bottom. I use a fragment identifier in the form action, because the form re-displays on post when there are errors, and I don't want the user to have to scroll down to it to make corrections.
When the form is successfully processed, I perform a redirect to the same page and display a confirmation message. The problem I am having is that the browser preserves the fragment identifier upon 302 redirects. Is there a trick to force the browser to clear/remove the fragment identifier?
Let's say I'm looking at a user profile page, and there's an address form on the page. The form action would be /user/profile#AddressForm
. If the form is submitted with errors, the page automatically is scrolled to the address form so the user can correct the errors. If there are no errors, I want to redirect to /user/profile
, which doesn't have the fragment identifier. The problem I am running into is that the browser retains the fragment identifier and the page scrolls back down to the form, instead of staying at the top.