Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save JackDanger/231490 to your computer and use it in GitHub Desktop.

Select an option

Save JackDanger/231490 to your computer and use it in GitHub Desktop.
diff --git a/jquery.validate.js b/jquery.validate.js
index c77350c..f9a940f 100644
--- a/jquery.validate.js
+++ b/jquery.validate.js
@@ -488,9 +488,12 @@ $.extend($.validator, {
check: function( element ) {
element = this.clean( element );
- // if radio/checkbox, validate first element in group instead
+ // if radio/checkbox, validate first visible element in group instead
if (this.checkable(element)) {
- element = this.findByName( element.name )[0];
+ var elementsByName = this.findByName( element.name )
+ element = $.grep(elementsByName, function(el) {
+ return $(el).is(":visible")
+ })[0] || elementsByName[0]
}
var rules = $(element).rules();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment