{"id":1125,"date":"2006-07-07T16:43:00","date_gmt":"2006-07-07T21:43:00","guid":{"rendered":"http:\/\/blogs.devhorizon.com\/reza\/?p=1125"},"modified":"2006-07-07T16:43:00","modified_gmt":"2006-07-07T21:43:00","slug":"how-to-prevent-users-from-multiple-submissions","status":"publish","type":"post","link":"https:\/\/blogs.devhorizon.com\/reza\/2006\/07\/07\/how-to-prevent-users-from-multiple-submissions\/","title":{"rendered":"How to prevent users from multiple submissions"},"content":{"rendered":"<p>I have been repeatedly asked about how to prevent users from clicking submit button more than once. If you have ever faced such a problem, you would probably know that there are many ways suggested by folks to handle this, things like using two buttons, disabling submit button using JavaScript and so on. Regrettably I never did find anything that worked like they said it would and more importantly some of those methods causes your server side events not to fire. The way I deal with this issue is not just disabling the button by greying it out, but not letting the form to be posted back using the code below:<BR>1) Put this in between the HEAD tags of your page: <BR><BR>&lt;HEAD&gt; <BR>&#8230; <BR>&nbsp; &lt;SCRIPT language=javascript&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp; var isSubmittedFlag= false; <BR>&nbsp; &lt;\/SCRIPT&gt; <BR>&#8230; <BR>&lt;\/HEAD&gt; <BR><BR>2) Add the following java script code to the button attributes collection in&nbsp; Page_Load() event of your page<BR><BR>btnSubmit.Attributes.Add(&#8220;onclick&#8221;, &#8220;javascript:if(isSubmittedFlag){alert(&#8216;Your first request is still being processed&#8217;);return false;}else{isSubmittedFlag=true;return true;}&#8221;) <BR><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have been repeatedly asked about how to prevent users from clicking submit button more than once. If you have ever faced such a problem, you would probably know that there are many ways suggested by folks to handle this, things like using two buttons, disabling submit button using JavaScript and so on. Regrettably I [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1125","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts\/1125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/comments?post=1125"}],"version-history":[{"count":0,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts\/1125\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/media?parent=1125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/categories?post=1125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/tags?post=1125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}