Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions Resources/Private/Build/JavaScript/PowermailConditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ class PowermailConditions {
activeElement.blur();

setTimeout(() => {
// don't submit if HTML validations fail
if (!this.#form.reportValidity()) {
if (this.#hasValidationErrors()) {
return;
}

Expand All @@ -91,10 +90,32 @@ class PowermailConditions {
}
}

if (this.#hasValidationErrors()) {
return;
}

this.#form.submit();
});
}

/**
* Check if the form has any validation errors, covering both native HTML5
* validation and powermail's JavaScript validation.
*
* Note: reportValidity() alone is not sufficient because it always returns
* true when the form has a "novalidate" attribute (i.e. when native
* validation is disabled via TypoScript validation.native = 0).
*/
#hasValidationErrors() {
if (!this.#form.reportValidity()) {
return true;
}
if (this.#form.classList.contains('powermail_form_error')) {
return true;
}
return false;
}

#fieldListener() {
const that = this;
const fields = this.#getFieldsFromForm();
Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/JavaScript/PowermailCondition.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.