Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The simplest solution to your problem is to disable the button and fields using javascript. Do you have any javascript libraries like jQuery in our page? </p> <pre><code>$('form').submit(function(){ $(this).find('input').prop('disabled', true) }); </code></pre> <p>Something like that for jQuery. If you have several forms you might want to add an id to the form to target only this one.</p> <p>UPDATE:</p> <p>As the problem with resubmitting there are no dead simple solution:</p> <p>To avoid the F5 problem. Make sure to redirect after the POST. Which you do, but I guess if it takes long time they might press F5 meanwhile. </p> <p>A few solutions on top of my head to this problem. </p> <ul> <li><p>(IF you are using SQL) Generate a guid that you place in a hidden field on the form page. Make this a unique column in the database and insert it with the rest of the information. If they try to resubmit SQL will protect you by throwing an exception you can handle. </p></li> <li><p>There are alternatives to the above technique. Maybe you store those guids in a separate table and check against that or maybe in XML or cache or whatever. </p></li> <li><p>When you submit the form add a timestamp with javascript. The first thing you do on the server is to make sure you are within x seconds from when the button was clicked. </p></li> <li><p>While submiting (After the first submit) you could add a warning with javascript. </p> <p>window.onbeforeunload = function(){ return 'Already saving! Please press no'; }; </p></li> </ul> <p>This last solution is not safe att all but very easy to add.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload