Unexpected form submit - html

I faced with a strange problem. I write ASP.NET web application.
I have form tag on the aspx page and submit in the form. When I click on the submit form's data are posted. It is ok. But if I close the page right after submit and then re-open it with Main Menu -> Recent Tabs (I use Google Chrome) the form's submit fires once again and data are posted too. I would like to avoid this behavior because repeated posting data to server is unwelcome and unexpected. It happens after select Recent Tabs only (when I prress Ctrl+Shift+T it does not happen) How could I prevent it? Thanks in advance

Check if it's a PostBack. If it is a PostBack then return.

Related

Form submit button value SOMETIMES is not POSTed in Chrome

NOT a duplicate of HTML Form Button value is not posted in Safari and Chrome
I have a button that is used to submit a form when it is clicked.
<form method="post" action="<URL>" class="login_form" name="login_form" id"login_form">
... various inputs here ...
<button type="submit" name="signIn" class="cta">
<span class="arrow">Enter</span>
</button>
</form>
The button name is used server-side to determine what action is to be taken (value is not provided because it is not used by the server).
The problem is that sometimes the name is not posted to the server, while sometimes it is. The ratio is about 1miss/6hits.
Many other forms on my website have the same structure, but I found this behaviour only for this one.
It seems to happen only with Chrome.
I tried clicking the button right after the page is loaded and after having waited quite some time after the page is fully loaded. so it seems not to be tied to the rest of the page.
Is this a known bug or could this be caused by something else?
I encountered a similar issue and in my case it was due to a JavaScript that on Form-Submit disabled the Submit-Button (the intention of that is to prevent duplicate POSTs when users double-click).
Disabled form elements are not included in the formdata.
A better way to "disable" it for the intent of preventing double-clicks thus may be setting pointer-events: none or preventing the surplus submits in JS (preventDefault).
It may also explain that it worked "sometimes", as I imagine there is room for a race between gathering the formdata and the button becoming disabled.
In my experience, this kind of error occurs when there is a problem with the coding of the form itself, or some related javascript error. The fact that you have tracked this to a 1 per 6 chance of happening supports this reasoning. What I would suggest is to view your console output, turn on persistent logging, then submit your forms and test. If this is indeed the problem, there will be some sort of error message printed on the console, and you will be able to solve the problem from there.

Form data re-appears on pressing back button in browser

I have a form on a webpage that submits post information to the server. All is working good except when i submit the form and press back button the data in the form re-appears instead of going to the previous web page. How can I prevent this? Also I want the previous web page to be reloaded again when i press back button.
Thank you.

Multiple times clicking form data saves that many records in chrome

I have a form built in Joomla 2.5 and ChronoForms, the form validation been done using MooTools. However in Chrome browser when I click multiple times the submit button, that many number of records get saved. This is not the issue in Mozilla or IE.
Is it a Chrome specific issue??
How can i disable the submit button on success of the validation??
Any feedback or solution is appreciated.
Regards,
happy coding
I figured this by adding a JavaScript code, which disabled the submit button after it was clicked and there were no validation error.
I had to modify some of the files from chronoform library to do this because when i added a normal JavaScript code, it used to disable the button after the submit button click, it did not check if the validation was fired or not, So, if the validation was fired i was not able to correct the validation error because it disabled my submit button.
Maybe check this "Prevent Double Submit" thread on the ChronoEngine forums:
http://chronoengine.com/forums/viewtopic.php?f=2&t=22439

Using a button as a link in HTML (form ASP.Net MVC 3)

My input pages have an OK and a Cancel button on them. These buttons are generated in a separate, partial view. The OK button is the submit for the form. The Cancel is a link to a different action. I can't make the Cancel button into a standard:
<form><input value="Cancel"></form>
as this would end up with nested forms which doesn't work (The form is on the outer, master view).
I can use Javascript, but I was hoping to have a page that would work without it.
I tried:
<button type="button">Stuff</button>
This works fine on Firefox, but does nothing on IE. Am I missing something here? Is there a simple way to get a button to work as a hyperlink?
You can always make the cancel button submit the form and make the redirect on the server side
you could CSS-style your link to look like a button.

Error with IE and form data when clicking back

Say if I am on page 1 , I enter my form data and go to page 2 , But wait I forgot something and I need to go back. FireFox and Safari ask me if I want to resend my form data.
But IE being IE it just goes back and does not show the page.
Is there away around this when I click back it keeps the data and the page appears.
Sorry I cannot give a link but the process for u to go through on my site to get to this part would take you a while.
My suspicion is that your talking about a wizard form. Where each part of the form is a page and you can go backwards and forwards through the pages.
the back button has always caused problems for developers on the web and this is probably the most annoying.
You can stop the IE back button issue by redirecting on the server to the next page when you receive a form post rather than just delivering the form back to the browser. Doing this means that the browser considers each page to have been a get and stops asking you if you want to resubmit the form.
to do this simply make each form post to itself and then return a redirect to the next page of the wizard. I'd give examples but I'm not sure what language you are using on the server.
the other alternative is to use javascript to create a wizard from your form see this jQuery wizard form demo.
create a new back button besides the submit button and when a user clicks on either one you call a javascript function which modifies the form action either to the next page or the previous page.