Bugzilla – Attachment 193838 Details for
Bug 41926
Disable OPAC search form after first submitting it, as a counter measure to spam
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41926: Add JS to prevent forms from resubmitting
Bug-41926-Add-JS-to-prevent-forms-from-resubmittin.patch (text/plain), 1.52 KB, created by
Lari Taskula
on 2026-02-25 10:03:20 UTC
(
hide
)
Description:
Bug 41926: Add JS to prevent forms from resubmitting
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2026-02-25 10:03:20 UTC
Size:
1.52 KB
patch
obsolete
>From edb4f2309c82e8bc4ea49df1694422b0f8eb326f Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Wed, 25 Feb 2026 11:53:38 +0200 >Subject: [PATCH] Bug 41926: Add JS to prevent forms from resubmitting > >--- > .../opac-tmpl/bootstrap/js/form-submit.js | 28 +++++++++++++++++++ > 1 file changed, 28 insertions(+) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/form-submit.js b/koha-tmpl/opac-tmpl/bootstrap/js/form-submit.js >index bcaaaa72ca8..e6af7d598b1 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/js/form-submit.js >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/form-submit.js >@@ -38,3 +38,31 @@ $("body").on("click", ".submit-form-link", function (e) { > e.preventDefault(); > submit_form(this); > }); >+ >+let forms_submitting = []; >+$("body").on("submit", "form.submit-form-prevent-resubmit", function (e) { >+ let should_we_send_it = true; >+ forms_submitting.forEach(el => { >+ if (el.is(this)) { >+ should_we_send_it = false; >+ } >+ }); >+ >+ if (!should_we_send_it) { >+ e.preventDefault(); >+ return false; >+ } >+ >+ forms_submitting.push($(this)); >+}); >+ >+$("body").on("change", "form.submit-form-prevent-resubmit", function (e) { >+ let form_el = $(this); >+ // If user is able to change the form before the next page loads, >+ // allow them to resubmit the form with the new values >+ forms_submitting.forEach(function (item, index, object) { >+ if ($(item).attr("id") === form_el.attr("id")) { >+ object.splice(index, 1); >+ } >+ }); >+}); >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41926
:
193835
| 193838 |
193839