vendor/assets/js/foundation.abide.js.es6 in foundation-rails-6.2.4.0 vs vendor/assets/js/foundation.abide.js.es6 in foundation-rails-6.3.0.0
- old
+ new
@@ -60,10 +60,18 @@
.off('input.zf.abide')
.on('input.zf.abide', (e) => {
this.validateInput($(e.target));
});
}
+
+ if (this.options.validateOnBlur) {
+ this.$inputs
+ .off('blur.zf.abide')
+ .on('blur.zf.abide', (e) => {
+ this.validateInput($(e.target));
+ });
+ }
}
/**
* Calls necessary functions to update Abide upon DOM change
* @private
@@ -276,10 +284,23 @@
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);
/**
* Fires when the input is done checking for validation. Event trigger is either `valid.zf.abide` or `invalid.zf.abide`
* Trigger includes the DOM element of the input.
@@ -487,9 +508,16 @@
* Set to true to validate text inputs on any value change.
* @option
* @example false
*/
liveValidate: false,
+
+ /**
+ * Set to true to validate inputs on blur.
+ * @option
+ * @example false
+ */
+ validateOnBlur: false,
patterns: {
alpha : /^[a-zA-Z]+$/,
alpha_numeric : /^[a-zA-Z0-9]+$/,
integer : /^[-+]?\d+$/,