to my surprise, I couldn't find any information on this topic, but then, searching for such things always yields a lot of similar but unrelated things...
Anyway, some notes to avoid misunderstandings: - The question is about HTML, HTTP, Javascript, and Browser behavior. I'm intentionally not speaking about server-side technology because I think making that part work won't be a problem for me. - I'm not aiming at security, nor do I want to restrict the user in what he/she does. In fact, I want to improve the UI.
Suppose we have an HTML page with a POST-redirect-GET form. Submitting the form causes server-side validation, followed either by results or validation errors. Now suppose it took a few attempts to get all values valid. The URL stays the same, though I have tried using changing URLs. Now the user looks at the result, then wants to go back to whatever page linked to the form. For a nice user interface, this should take 2 clicks on the back button, one to return from the results page to the form, and a second to return to the page before the form. Instead, however, the user has to click past each failed attempt to enter valid values.
How can I avoid this? Note again that I don't want to "hide" anything from the user, just there is no practical case where invalid form values are useful. I found hints that a "single-page application" suffers from related problems due to NOT filling the history, but that's actually the opposite problem, and my application is not "single-page".
As an alternative to avoiding history entries, I'm also perfectly fine with side-stepping the problem in some way, or even building a good user interface around it. But right now, the button says "back" (in the sense of navigation) but does "undo" (in the sense of changing values) to the form. People expect the back button to go back -- they already have ctrl-z for undo.
The straightforward solution -- though I couldn't find anything like that -- would be an HTTP header that says, "here's an updated version of the same resource you requested before, note how it has the same URL, so don't make it appear twice when back-button-ing".
I think the simplest approach would be to use ajax to process your form submission even if it is a multi-part form.
I would have a combination of client side validation to give quicker feedback to your user, and then handle server side validation errors when you receive your return data from the ajax request.
With this method your browser history should be relatively preserved and not filled with success/failure form submissions.
I personally like this client side bootstrap validator plugin:
https://github.com/1000hz/bootstrap-validator
I also use it to update the interface when I get an error message returned from the server.