Skip to content
Snippets Groups Projects
Commit 00b4eea8 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by Jan-Hendrik Willms
Browse files

check validity of forms before proceeding, fixes #772

Closes #772

Merge request studip/studip!412
parent f0e79924
No related branches found
No related tags found
No related merge requests found
...@@ -667,9 +667,17 @@ Dialog.removeHeaderHandler = function (header) { ...@@ -667,9 +667,17 @@ Dialog.removeHeaderHandler = function (header) {
}; };
Dialog.initialize = function() { Dialog.initialize = function() {
function checkValidity(element) {
const form = element.closest('form');
if (form === null) {
return true;
}
return form.checkValidity();
}
// Actual dialog handler // Actual dialog handler
function dialogHandler(event) { function dialogHandler(event) {
if (!event.isDefaultPrevented()) { if (!event.isDefaultPrevented() && checkValidity(event.target)) {
var target = $(event.target).closest('[data-dialog]'); var target = $(event.target).closest('[data-dialog]');
var options = target.data().dialog; var options = target.data().dialog;
if (Dialog.fromElement(target, parseOptions(options))) { if (Dialog.fromElement(target, parseOptions(options))) {
...@@ -679,7 +687,7 @@ Dialog.initialize = function() { ...@@ -679,7 +687,7 @@ Dialog.initialize = function() {
} }
function clickHandler(event) { function clickHandler(event) {
if (!event.isDefaultPrevented()) { if (!event.isDefaultPrevented() && checkValidity(event.target)) {
var element = $(event.target).closest(':submit,input[type="image"]'); var element = $(event.target).closest(':submit,input[type="image"]');
var form = element.closest('form'); var form = element.closest('form');
var action = element.attr('formaction'); var action = element.attr('formaction');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment