vendor/assets/js/foundation.abide.js.es6 in foundation-rails-6.3.0.0 vs vendor/assets/js/foundation.abide.js.es6 in foundation-rails-6.3.1.0
- old
+ new
@@ -108,26 +108,31 @@
return isGood;
}
/**
- * Based on $el, get the first element with selector in this order:
- * 1. The element's direct sibling('s).
- * 3. The element's parent's children.
+ * Get:
+ * - Based on $el, the first element(s) corresponding to `formErrorSelector` in this order:
+ * 1. The element's direct sibling('s).
+ * 2. The element's parent's children.
+ * - Element(s) with the attribute `[data-form-error-for]` set with the element's id.
*
* This allows for multiple form errors per input, though if none are found, no form errors will be shown.
*
* @param {Object} $el - jQuery object to use as reference to find the form error selector.
* @returns {Object} jQuery object with the selector.
*/
findFormError($el) {
+ var id = $el[0].id;
var $error = $el.siblings(this.options.formErrorSelector);
if (!$error.length) {
$error = $el.parent().find(this.options.formErrorSelector);
}
+ $error = $error.add(this.$element.find(`[data-form-error-for="${id}"]`));
+
return $error;
}
/**
* Get the first element in this order:
@@ -235,11 +240,12 @@
$el.removeClass(this.options.inputErrorClass).removeAttr('data-invalid');
}
/**
- * Goes through a form to find inputs and proceeds to validate them in ways specific to their type
+ * Goes through a form to find inputs and proceeds to validate them in ways specific to their type.
+ * Ignores inputs with data-abide-ignore, type="hidden" or disabled attributes set
* @fires Abide#invalid
* @fires Abide#valid
* @param {Object} element - jQuery object to validate, should be an HTML input
* @returns {Boolean} goodToGo - If the input is valid or not.
*/
@@ -248,12 +254,12 @@
validated = false,
customValidator = true,
validator = $el.attr('data-validator'),
equalTo = true;
- // don't validate ignored inputs or hidden inputs
- if ($el.is('[data-abide-ignore]') || $el.is('[type="hidden"]')) {
+ // don't validate ignored inputs or hidden inputs or disabled inputs
+ if ($el.is('[data-abide-ignore]') || $el.is('[type="hidden"]') || $el.is('[disabled]')) {
return true;
}
switch ($el[0].type) {
case 'radio':
@@ -470,52 +476,59 @@
Abide.defaults = {
/**
* The default event to validate inputs. Checkboxes and radios validate immediately.
* Remove or change this value for manual validation.
* @option
- * @example 'fieldChange'
+ * @type {?string}
+ * @default 'fieldChange'
*/
validateOn: 'fieldChange',
/**
* Class to be applied to input labels on failed validation.
* @option
- * @example 'is-invalid-label'
+ * @type {string}
+ * @default 'is-invalid-label'
*/
labelErrorClass: 'is-invalid-label',
/**
* Class to be applied to inputs on failed validation.
* @option
- * @example 'is-invalid-input'
+ * @type {string}
+ * @default 'is-invalid-input'
*/
inputErrorClass: 'is-invalid-input',
/**
* Class selector to use to target Form Errors for show/hide.
* @option
- * @example '.form-error'
+ * @type {string}
+ * @default '.form-error'
*/
formErrorSelector: '.form-error',
/**
* Class added to Form Errors on failed validation.
* @option
- * @example 'is-visible'
+ * @type {string}
+ * @default 'is-visible'
*/
formErrorClass: 'is-visible',
/**
* Set to true to validate text inputs on any value change.
* @option
- * @example false
+ * @type {boolean}
+ * @default false
*/
liveValidate: false,
/**
* Set to true to validate inputs on blur.
* @option
- * @example false
+ * @type {boolean}
+ * @default false
*/
validateOnBlur: false,
patterns: {
alpha : /^[a-zA-Z]+$/,