aw-front-helpers 2.5.22 → 2.5.24
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/classes/formControl.js +28 -2
- package/package.json +1 -1
package/classes/formControl.js
CHANGED
|
@@ -112,6 +112,25 @@ export default class FormControl {
|
|
|
112
112
|
this._formGrabDom();
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
addControl(el, controlName, test, errorMessage) {
|
|
116
|
+
if(!el) return
|
|
117
|
+
el.specialControls = el.specialControls || {};
|
|
118
|
+
el.specialControls[controlName] = {
|
|
119
|
+
isValid: () => test(el.value), errorMessage
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
checkError(el) {
|
|
124
|
+
this._checkError(el);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
removeControl(el, controlName) {
|
|
128
|
+
if(!el) return
|
|
129
|
+
if(el.specialControls && el.specialControls[controlName]) {
|
|
130
|
+
delete el.specialControls[controlName];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
115
134
|
removeErrors(el = null) {
|
|
116
135
|
this._removeError(el);
|
|
117
136
|
}
|
|
@@ -248,7 +267,14 @@ export default class FormControl {
|
|
|
248
267
|
invalid = true;
|
|
249
268
|
this.setError(el, this._options.i18n.same);
|
|
250
269
|
}
|
|
251
|
-
|
|
270
|
+
if( el.specialControls ) {
|
|
271
|
+
for( let key in el.specialControls ) {
|
|
272
|
+
if( !el.specialControls[key].isValid() ) {
|
|
273
|
+
invalid = true;
|
|
274
|
+
this.setError(el, el.specialControls[key].errorMessage);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
252
278
|
return invalid;
|
|
253
279
|
}
|
|
254
280
|
|
|
@@ -287,7 +313,7 @@ export default class FormControl {
|
|
|
287
313
|
this._domForm = {};
|
|
288
314
|
this._domForm.inputs = [
|
|
289
315
|
...this._form.querySelectorAll(
|
|
290
|
-
'input[type=text],input[type=date],input[type=number],input[type=password],input[type=hidden],input[type=search],input[type=email],input[type=tel],textarea'
|
|
316
|
+
'input[type=text],input[type=date],input[type=time],input[type=number],input[type=password],input[type=hidden],input[type=search],input[type=email],input[type=tel],textarea'
|
|
291
317
|
),
|
|
292
318
|
];
|
|
293
319
|
this._domForm.choices = [
|