From c3429858af39c19f0d31db779f084def46fa592d Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Tue, 11 Jul 2017 19:03:32 +0000 Subject: [PATCH] * form: Block the submit button to not allow Chrome/Edge to submit multiple times in case of multiple clicks on slow server git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3806 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- form.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/form.php b/form.php index 468ab00..a74ddce 100644 --- a/form.php +++ b/form.php @@ -838,6 +838,16 @@ class formfield $res .= " class='form-control btn-primary'"; if (isset ($this->hidden) && $this->hidden !== FALSE) $res .= " style='display:none'"; + // Block the submit button 10s. The user can not double click on it and + // submit two times the POST to the server + // Re-enable after 15s, if there is a problem with the server + // This code is needed by Chrome and Edge which allow multiple submission of + // a form + $res .= " onclick='submit=this ; "; + $res .= "submit.setAttribute(\"disabled\", \"disabled\");"; + $res .= " setTimeout(function() {"; + $res .= " submit.removeAttribute(\"disabled\"); }, 15000);"; + $res .= "'"; $res .= "/>\n"; $res .= " \n"; $res .= " \n";