adt-js-components 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/SubmitForm/index.js +12 -2
package/package.json
CHANGED
package/src/SubmitForm/index.js
CHANGED
|
@@ -73,10 +73,16 @@ function run(options) {
|
|
|
73
73
|
el.innerHTML = '';
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
+
const alertErrors = [];
|
|
76
77
|
for (const error of errors) {
|
|
77
78
|
// because radio lists and checkbox lists contains one error message multiple times
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
const errorElementId = 'snippet-' + getErrorElementId(error.element) + '-errors';
|
|
80
|
+
const errorElement = document.getElementById(errorElementId);
|
|
81
|
+
if (!errorElement) {
|
|
82
|
+
alertErrors.push(error.message);
|
|
83
|
+
console.warn(`Element with ID "${errorElementId}" no exist.`);
|
|
84
|
+
} else if (!errorElement.innerHTML.includes(error.message)) {
|
|
85
|
+
errorElement.innerHTML += `<div>${error.message}</div>`;
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
error.element.classList.add('is-invalid');
|
|
@@ -93,6 +99,10 @@ function run(options) {
|
|
|
93
99
|
if (errors.length) {
|
|
94
100
|
scrollToFirstError(form);
|
|
95
101
|
}
|
|
102
|
+
|
|
103
|
+
if (alertErrors.length) {
|
|
104
|
+
alert(alertErrors.join('\n'));
|
|
105
|
+
}
|
|
96
106
|
};
|
|
97
107
|
} else {
|
|
98
108
|
console.error('Package nette-forms is missing!');
|