@modernman00/shared-js-lib 1.2.28 → 1.2.30
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/AcctMgt/processAll.js +0 -1
- package/FormHelper.js +14 -9
- package/Http.js +2 -1
- package/config/version.php +1 -1
- package/package.json +1 -1
package/AcctMgt/processAll.js
CHANGED
package/FormHelper.js
CHANGED
|
@@ -101,7 +101,7 @@ export default class FormHelper {
|
|
|
101
101
|
|
|
102
102
|
for (let input of this.data) {
|
|
103
103
|
const { name, value, id, type, placeholder } = input;
|
|
104
|
-
|
|
104
|
+
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
// Skip non-input elements
|
|
@@ -109,16 +109,18 @@ export default class FormHelper {
|
|
|
109
109
|
['submit', 'button', 'g-recaptcha-response', 'cancel'].includes(name) ||
|
|
110
110
|
['button', 'showPassword_id', 'token', 'g-recaptcha-response'].includes(id) ||
|
|
111
111
|
type === 'button' ||
|
|
112
|
-
|
|
112
|
+
id === 'checkbox_id'
|
|
113
113
|
) continue;
|
|
114
114
|
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
// remove _id from id if it exists to create a clean label
|
|
117
|
+
const cleanID = id.endsWith('_id') ? id.slice(0, -3) : id;
|
|
118
|
+
let label = cleanID.replace(/_/g, ' '); // For readable error text
|
|
119
|
+
const errorEl = this.id(`${cleanID}_error`);
|
|
118
120
|
let val = value.trim();
|
|
119
121
|
|
|
120
122
|
// Handle optional fields
|
|
121
|
-
if (optionalFields.includes(
|
|
123
|
+
if (optionalFields.includes(id) && val === '') {
|
|
122
124
|
input.value = 'Not Provided';
|
|
123
125
|
continue;
|
|
124
126
|
}
|
|
@@ -131,9 +133,9 @@ export default class FormHelper {
|
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
// Determine field type for regex
|
|
134
|
-
let validateType = typeMap[
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
let validateType = typeMap[id] || (
|
|
137
|
+
id.toLowerCase().includes('email') ? 'email' :
|
|
138
|
+
id.toLowerCase().includes('password') ? 'password' : 'general'
|
|
137
139
|
);
|
|
138
140
|
|
|
139
141
|
if (!this.matchRegex(val, validateType)) {
|
|
@@ -187,8 +189,11 @@ export default class FormHelper {
|
|
|
187
189
|
return;
|
|
188
190
|
}
|
|
189
191
|
|
|
192
|
+
// remove _id from id if it exists
|
|
193
|
+
const cleanID = id.endsWith('_id') ? id.slice(0, -3) : id;
|
|
194
|
+
|
|
190
195
|
// Add event listeners to clear errors
|
|
191
|
-
const clearErrorHandler = () => clearErrorForElement(name);
|
|
196
|
+
const clearErrorHandler = () => clearErrorForElement(cleanID || name);
|
|
192
197
|
if (value !== 'select') element.addEventListener('keyup', clearErrorHandler);
|
|
193
198
|
element.addEventListener('change', clearErrorHandler);
|
|
194
199
|
});
|
package/Http.js
CHANGED
|
@@ -34,7 +34,8 @@ export const postFormData = async (url, formId, redirect = null, css = null) =>
|
|
|
34
34
|
// }
|
|
35
35
|
|
|
36
36
|
// extract the form entries
|
|
37
|
-
|
|
37
|
+
// extract the form entriesËËË
|
|
38
|
+
const form = id(formId)
|
|
38
39
|
|
|
39
40
|
if (!form) {
|
|
40
41
|
throw new Error('Form element not found');
|
package/config/version.php
CHANGED
package/package.json
CHANGED