Skip to content

Commit 0ee489b

Browse files
committed
Reject empty values when a reason is required
See https://www.woltlab.com/community/thread/317041/
1 parent d1a2289 commit 0ee489b

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

ts/WoltLabSuite/Core/Component/Confirmation.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,20 @@ class ConfirmationPrefab {
150150

151151
dialog.content.append(dl);
152152

153+
if (!isOptional) {
154+
dialog.addEventListener("validate", (event) => {
155+
if (reason.value.trim() === "") {
156+
event.preventDefault();
157+
158+
dl.classList.add("formError");
159+
DomUtil.innerError(reason, getPhrase("wcf.global.form.error.empty"));
160+
} else {
161+
dl.classList.remove("formError");
162+
DomUtil.innerError(reason, false);
163+
}
164+
});
165+
}
166+
153167
dialog.show(question);
154168

155169
return new Promise<ResultConfirmationWithReason>((resolve) => {

wcfsetup/install/files/js/WoltLabSuite/Core/Component/Confirmation.js

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)