diff --git a/index.html b/index.html index bcfe975..be31308 100644 --- a/index.html +++ b/index.html @@ -149,15 +149,15 @@
- - -
This field dynamically enables/disables the 'Dependant Child' field if it has a value.
+ + +
This field dynamically enables/disables the 'Dependent Child' field if it has a value.
- - -
This field dynamically enables/disables if the 'Dependant Parent' field has a value.
+ + +
This field dynamically enables/disables if the 'Dependent Parent' field has a value.
diff --git a/validation.js b/validation.js index 7d75e57..b37e836 100644 --- a/validation.js +++ b/validation.js @@ -1,5 +1,5 @@ class ValidationField { - dependant = null + dependent = null el = null formGroupEl = null isValid = null @@ -96,12 +96,12 @@ class ValidationField { // add a native pattern attr if pattern property is present if (this.pattern) this.el.setAttribute('pattern', this.pattern) - // dependant fields - if (this.dependant) { - const parents = this.validationInstance.form.querySelectorAll(`[name="${this.dependant}"]`) + // dependent fields + if (this.dependent) { + const parents = this.validationInstance.form.querySelectorAll(`[name="${this.dependent}"]`) const depCheck = () => { - if (((parents[0].type === 'checkbox' || parents[0].type === 'radio') && this.validationInstance.form.querySelectorAll(`[name="${this.dependant}"]:checked`).length > 0) || + if (((parents[0].type === 'checkbox' || parents[0].type === 'radio') && this.validationInstance.form.querySelectorAll(`[name="${this.dependent}"]:checked`).length > 0) || (((parents[0].type !== 'checkbox' && parents[0].type !== 'radio') && parents[0].value))) { this.el.removeAttribute('disabled') } else {