Created
June 28, 2010 16:12
-
-
Save orip/456034 to your computer and use it in GitHub Desktop.
Revisions
-
orip revised this gist
Jun 28, 2010 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ // jQuery.validate.requiredIfVisible.js // Copyright (c) 2010 Ori Peleg, http://orip.org, distributed under the MIT license (function($) { $.validator.addMethod( -
orip revised this gist
Jun 28, 2010 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ // Copyright (c) 2010 Ori Peleg, http://orip.org, distributed under the MIT license (function($) { $.validator.addMethod( "requiredIfVisible", -
orip revised this gist
Jun 28, 2010 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ // Copyright (c) 2010 Ori Peleg, distributed under the MIT license (function($) { $.validator.addMethod( "requiredIfVisible", @@ -7,13 +8,14 @@ $.validator.addMethod( // inspiration: http://remysharp.com/2008/10/17/jquery-really-visible/ return e.is(":visible") && e.parents(":not(:visible)").length == 0; } if (isVisible($(element))) { // call the "required" method return $.validator.methods.required.call(this, $.trim(element.value), element); } return true; }, $.validator.messages.required ); })(jQuery); -
orip revised this gist
Jun 28, 2010 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,7 @@ $.validator.addMethod( function(value, element, params) { function isVisible(e) { // the element and all of its parents must be :visible // inspiration: http://remysharp.com/2008/10/17/jquery-really-visible/ return e.is(":visible") && e.parents(":not(:visible)").length == 0; } if (isVisible($(element))) { -
orip created this gist
Jun 28, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ (function($) { $.validator.addMethod( "requiredIfVisible", function(value, element, params) { function isVisible(e) { // the element and all of its parents must be :visible return e.is(":visible") && e.parents(":not(:visible)").length == 0; } if (isVisible($(element))) { // call the "required" method return $.validator.methods.required.call(this, $.trim(element.value), element); } return true; }, "Required" ); })(jQuery);