]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Make Abide also re-validate dependent fields (with equalto). 9275/head
authorMarius Olbertz <marius.olbertz@gmail.com>
Tue, 18 Oct 2016 18:32:39 +0000 (20:32 +0200)
committerMarius Olbertz <marius.olbertz@gmail.com>
Tue, 18 Oct 2016 18:32:39 +0000 (20:32 +0200)
Addresses #9138.

js/foundation.abide.js

index 5c8750da303418d50c1e8d62f9ff6459f4227ec8..b58cb226265c68e84e4bb6a79c4fd1cc4b46be04 100644 (file)
@@ -278,6 +278,19 @@ class Abide {
     var goodToGo = [clearRequire, validated, customValidator, equalTo].indexOf(false) === -1;
     var message = (goodToGo ? 'valid' : 'invalid') + '.zf.abide';
 
+    if (goodToGo) {
+      // Re-validate inputs that depend on this one with equalto
+      const dependentElements = this.$element.find(`[data-equalto="${$el.attr('id')}"]`);
+      if (dependentElements.length) {
+        let _this = this;
+        dependentElements.each(function() {
+          if ($(this).val()) {
+            _this.validateInput($(this));
+          }
+        });
+      }
+    }
+
     this[goodToGo ? 'removeErrorClasses' : 'addErrorClasses']($el);
 
     /**