Skip to content
This repository has been archived by the owner on Aug 17, 2020. It is now read-only.

Commit

Permalink
Re-add sibling checking in a more graceful format
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy-set-studio committed Apr 10, 2018
1 parent bd593fb commit 9995b3d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion assets/js/modules/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class Validation {
self.inputElems.map(item => {
item.addEventListener('invalid', () => {
self.processValidity(item);
self.checkSiblings(item);
}, false);
});
}
Expand All @@ -48,7 +49,20 @@ export default class Validation {
default:
item.classList.remove('is-error');
break;
}
}
}

/**
* Filter sibling elements and run them through the validity checker
*
* @param {HTMLFormElement} exludedField
*/
checkSiblings(exludedField) {
let self = this;

self.inputElems
.filter(item => item !== exludedField)
.map(item => self.processValidity(item));
}

/**
Expand Down

0 comments on commit 9995b3d

Please sign in to comment.