From: Matthias Schmidt Date: Thu, 10 Jun 2021 07:01:57 +0000 (+0200) Subject: Sync client-side poll validation with server-side validation X-Git-Tag: 5.3.8~5 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2393f5e44219338430a5a87c34e491ff35df0e40;p=GitHub%2FWoltLab%2FWCF.git Sync client-side poll validation with server-side validation `PollManager` marks an empty question field as empty if poll options are given, while `WCF.Poll.Management` aborted validation once the question field is empty, no matter whether options are given or not. --- diff --git a/wcfsetup/install/files/js/WCF.Poll.js b/wcfsetup/install/files/js/WCF.Poll.js index 290423d6ea..93edea6b9d 100644 --- a/wcfsetup/install/files/js/WCF.Poll.js +++ b/wcfsetup/install/files/js/WCF.Poll.js @@ -282,12 +282,6 @@ if (COMPILER_TARGET_DEFAULT) { }, _validate: function (data) { - var question = elById('pollQuestion_' + this._editorId); - if (question.value.trim() === '') { - // no question provided, ignore - return; - } - // get options var count = 0; elBySelAll('li input[type="text"]', this._container[0], function (input) { @@ -296,6 +290,18 @@ if (COMPILER_TARGET_DEFAULT) { } }); + var question = elById('pollQuestion_' + this._editorId); + if (question.value.trim() === '') { + if (count === 0) { + // no question and no options provided, ignore + return; + } + else { + data.api.throwError(question, WCF.Language.get('wcf.global.form.error.empty')); + data.valid = false; + } + } + if (count === 0) { data.api.throwError(this._container[0], WCF.Language.get('wcf.global.form.error.empty')); data.valid = false;