Content-Length: 2892 | pFad | http://github.com/jquery-validation/jquery-validation/pull/637.diff

thub.com diff --git a/jquery.validate.js b/jquery.validate.js index 3c02627ab..bdf938366 100644 --- a/jquery.validate.js +++ b/jquery.validate.js @@ -1152,7 +1152,7 @@ $.extend($.validator, { equalTo: function( value, element, param ) { // bind to the blur event of the target in order to revalidate whenever the target field is updated // TODO find a way to bind the event just once, avoiding the unbind-rebind overhead - var target = $(param); + var target = $(param, element.form); if ( this.settings.onfocusout ) { target.unbind(".validate-equalTo").bind("blur.validate-equalTo", function() { $(element).valid(); diff --git a/test/index.html b/test/index.html index bb9fc4ad8..0c4aae0f6 100644 --- a/test/index.html +++ b/test/index.html @@ -108,6 +108,11 @@

+
+ + +
+
@@ -181,6 +186,7 @@

+ diff --git a/test/methods.js b/test/methods.js index 36ddde727..a90f1967d 100644 --- a/test/methods.js +++ b/test/methods.js @@ -333,9 +333,10 @@ test("range", function() { test("equalTo", function() { var v = jQuery("#form").validate(); var method = $.validator.methods.equalTo, - e = $('#text1, #text2'); + e = $('#text1, #text2, #form input[name=text3]'); ok( method.call( v, "Test", e[0], "#text1"), "Text input" ); ok( method.call( v, "T", e[1], "#text2"), "Another one" ); + ok( method.call( v, "T", e[2], "input[name=text3]"), "Find by name" ); }); test("creditcard", function() { diff --git a/test/test.js b/test/test.js index 1b6589874..2232848b3 100644 --- a/test/test.js +++ b/test/test.js @@ -170,6 +170,16 @@ test("form(): with equalTo", function() { ok( v.form(), 'Valid form' ); }); +test("form(): with equalTo and selectors by name", function() { + expect( 2 ); + var form = $('#testForm5_1')[0]; + var v = $(form).validate(); + console.log("v.form=" + v.form()); + ok( !v.form(), 'Invalid form' ); + $('[name=x1], [name=x2]', form).val("hi"); + ok( v.form(), 'Valid form' ); +}); + test("form(): with equalTo and onfocusout=false", function() { expect( 4 ); var form = $('#testForm5')[0];







ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/jquery-validation/jquery-validation/pull/637.diff

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy