It may sound like a beast question, but I'm amazed that when I click the back button, the form is sent.
The code looks like 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 this: when I click Back, it should redirect me to a desired URL, the form is SENT, and then it is redirected to the URL, which I do not understand is why the form is being sent.
I have tried the form described above to use preventDefault, disable beforeunload, return false, but the form is still sent.
How do I block this behavior? I'm testing on firefox.
PS: function: functionvalidation (this) is returning false for test purposes. The palliative solution I found was to remove the 'form' element, but I believe this is not the correct alternative. I checked the link link that disabling the element is also not possible.