From 8d40c84945d71083c9de6f17210fb20e4579dcc9 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 12 May 2022 12:34:19 +0000 Subject: [PATCH] check validity of forms before proceeding, fixes #772 Closes #772 Merge request studip/studip!412 --- resources/assets/javascripts/lib/dialog.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/assets/javascripts/lib/dialog.js b/resources/assets/javascripts/lib/dialog.js index bc649703a1d..5418f91589c 100644 --- a/resources/assets/javascripts/lib/dialog.js +++ b/resources/assets/javascripts/lib/dialog.js @@ -672,9 +672,17 @@ Dialog.removeHeaderHandler = function (header) { }; Dialog.initialize = function() { + function checkValidity(element) { + const form = element.closest('form'); + if (form === null) { + return true; + } + return form.checkValidity(); + } + // Actual dialog handler function dialogHandler(event) { - if (!event.isDefaultPrevented()) { + if (!event.isDefaultPrevented() && checkValidity(event.target)) { var target = $(event.target).closest('[data-dialog]'); var options = target.data().dialog; if (Dialog.fromElement(target, parseOptions(options))) { @@ -684,7 +692,7 @@ Dialog.initialize = function() { } function clickHandler(event) { - if (!event.isDefaultPrevented()) { + if (!event.isDefaultPrevented() && checkValidity(event.target)) { var element = $(event.target).closest(':submit,input[type="image"]'); var form = element.closest('form'); var action = element.attr('formaction'); -- GitLab