From 3c7fa1b364138e545fab23f9c299804ffcf847a6 Mon Sep 17 00:00:00 2001 From: leonardospina Date: Thu, 29 Nov 2018 11:04:04 +0000 Subject: [PATCH 1/3] Core: Call to resetInternals removed in remote validation callback --- src/core.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core.js b/src/core.js index 08352d41c..54fbee7fa 100644 --- a/src/core.js +++ b/src/core.js @@ -1570,7 +1570,6 @@ $.extend( $.validator, { validator.settings.messages[ element.name ][ method ] = previous.originalMessage; if ( valid ) { submitted = validator.formSubmitted; - validator.resetInternals(); validator.toHide = validator.errorsFor( element ); validator.formSubmitted = submitted; validator.successList.push( element ); From 7a5bcd430231725cee8ab3b39939a77026730049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Tsch=C3=A4pp=C3=A4t?= Date: Mon, 23 Jan 2023 13:31:06 +0100 Subject: [PATCH 2/3] Core: Add unit test for issue #2150 fix --- test/index.html | 4 ++++ test/test.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/test/index.html b/test/index.html index bf22a640a..02e3d8a1a 100644 --- a/test/index.html +++ b/test/index.html @@ -71,6 +71,10 @@

+
+
+ +
diff --git a/test/test.js b/test/test.js index 870d625d5..827955381 100644 --- a/test/test.js +++ b/test/test.js @@ -2051,6 +2051,38 @@ QUnit.test( "[Remote rule] #1508: Validation fails to trigger when next field is check( "abc" ); } ); + +$.mockjax({ + url: "issue2150TestForm.action", + response: function() { + this.responseText = "true"; + }, + responseTime: 1 +}); + +QUnit.test("Remote validation should not reset existing errors (#2150)", function( assert ) { + assert.expect( 3 ); + var done = assert.async(); + $("#issue2150TestForm").validate({ + rules: { + remoteTestedInput: { + remote: "issue2150TestForm.action" + }, + requiredInput: "required", + } + }); + + assert.equal( $( "#requiredInput" ).attr( "class" ), undefined, "#requiredInput should not have any class" ); + + var isValid = $( "#issue2150TestForm" ).valid(); + + setTimeout(function() { + assert.equal( $( "#requiredInput" ).attr( "class" ), "error", "#requiredInput should have \"error\" class" ); + assert.equal( isValid, false, "Form should have error" ); + done(); + }); +}); + QUnit.test( "validate checkbox on click", function( assert ) { function errors( expected, message ) { assert.equal( v.size(), expected, message ); From 89f8c6d1a44ddaf1b1f848d478159cb2f679e86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Tsch=C3=A4pp=C3=A4t?= Date: Mon, 23 Jan 2023 13:47:46 +0100 Subject: [PATCH 3/3] Core: fix code style errors --- test/test.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/test/test.js b/test/test.js index 832cae8bf..02462c933 100644 --- a/test/test.js +++ b/test/test.js @@ -2060,37 +2060,36 @@ QUnit.test( "[Remote rule] #1508: Validation fails to trigger when next field is check( "abc" ); } ); - -$.mockjax({ +$.mockjax( { url: "issue2150TestForm.action", response: function() { this.responseText = "true"; }, responseTime: 1 -}); +} ); -QUnit.test("Remote validation should not reset existing errors (#2150)", function( assert ) { +QUnit.test( "Remote validation should not reset existing errors (#2150)", function( assert ) { assert.expect( 3 ); var done = assert.async(); - $("#issue2150TestForm").validate({ + $( "#issue2150TestForm" ).validate( { rules: { remoteTestedInput: { remote: "issue2150TestForm.action" }, - requiredInput: "required", + requiredInput: "required" } - }); + } ); assert.equal( $( "#requiredInput" ).attr( "class" ), undefined, "#requiredInput should not have any class" ); var isValid = $( "#issue2150TestForm" ).valid(); - setTimeout(function() { + setTimeout( function() { assert.equal( $( "#requiredInput" ).attr( "class" ), "error", "#requiredInput should have \"error\" class" ); assert.equal( isValid, false, "Form should have error" ); done(); - }); -}); + } ); +} ); QUnit.test( "validate checkbox on click", function( assert ) { function errors( expected, message ) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy