1
It may seem like a stupid question but I’m amazed that when I click the back button, the form is sent.
The code is similar to this:
<form id="idform" method="post" onsubmit="return funcaodevalidacao(this);">
<!-- conteúdo do form -->
<input type="submit" value="Enviar"> <button onclick="window.location.href = 'URL'">Voltar</button>
</form>
<script>
$('form').submit(function (ev) {
ev.preventDefault();
$(window).unbind('beforeunload');
return false;
});
</script>
What happens is the following: when I click on Back, which should redirect me to a desired URL, the form is SENT, and then is redirected to the URL, what I don’t understand is why the form is being sent.
I tried the way described above to use preventDefault, disable beforeunload, return false, but the form is still sent.
How do I block this behavior? I’m testing in firefox.
PS: the function: function Devaluation(this) is returning false for test questions. The palliative solution I found was to remove the 'form' element, but I believe this is not the correct alternative. I checked the link http://www.w3.org/TR/html401/interact/forms.html#h-17.12 that disabling the element is also not possible.