From 2b2bd1d1fbf007a8e3fb8643c1231c76730b25ae Mon Sep 17 00:00:00 2001 From: eav Date: Fri, 26 Dec 2014 11:59:23 +0400 Subject: [PATCH] Exclude validates disabled form elements (checkbox, radio) --- js/foundation/foundation.abide.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/js/foundation/foundation.abide.js b/js/foundation/foundation.abide.js index 1b0e981ed..f9f42967c 100644 --- a/js/foundation/foundation.abide.js +++ b/js/foundation/foundation.abide.js @@ -242,7 +242,7 @@ valid_checkbox : function(el, required) { var el = this.S(el), - valid = (el.is(':checked') || !required); + valid = (el.is(':checked') || !required || el.get(0).getAttribute('disabled')); if (valid) { el.removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class); @@ -257,12 +257,24 @@ var name = el.getAttribute('name'), group = this.S(el).closest('[data-' + this.attr_name(true) + ']').find("[name='"+name+"']"), count = group.length, - valid = false; + valid = false, + disabled = false; // Has to count up to make sure the focus gets applied to the top error - for (var i=0; i < count; i++) { - if (group[i].checked) valid = true; - } + for (var i=0; i < count; i++) { + if( group[i].getAttribute('disabled') ){ + disabled=true; + valid=true; + } else { + if (group[i].checked){ + valid = true; + } else { + if( disabled ){ + valid = false; + } + } + } + } // Has to count up to make sure the focus gets applied to the top error for (var i=0; i < count; i++) { -- 2.47.2