Skip to content

Commit cfe74a1

Browse files
leonardospinaleonardospinaJulien Tschäppät
authored
Core: Call to resetInternals removed in remote validation callback (jquery-validation#2242)
* Core: Call to resetInternals removed in remote validation callback * Core: Add unit test for issue jquery-validation#2150 fix * Core: fix code style errors Co-authored-by: leonardospina <leo@babieleo.it> Co-authored-by: Julien Tschäppät <julien.tschappat@smartliberty.ch>
1 parent 13b859e commit cfe74a1

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

src/core.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,6 @@ $.extend( $.validator, {
16071607
validator.settings.messages[ element.name ][ method ] = previous.originalMessage;
16081608
if ( valid ) {
16091609
submitted = validator.formSubmitted;
1610-
validator.resetInternals();
16111610
validator.toHide = validator.errorsFor( element );
16121611
validator.formSubmitted = submitted;
16131612
validator.successList.push( element );

test/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ <h2 id="qunit-userAgent"></h2>
7272
<input type="text" data-rule-required="true" title="buga" name="lastname" id="lastname">
7373
<input type="text" data-rule-required="true" title="something" name="something" id="something" value="something">
7474
</form>
75+
<form id="issue2150TestForm">
76+
<input id="remoteTestedInput" type="text" name="remoteTestedInput" value="test" /><br/>
77+
<input id="requiredInput" type="text" name="requiredInput" value="" />
78+
</form>
7579
<form id="testForm1clean">
7680
<input title="buga" name="firstnamec" id="firstnamec">
7781
<label id="errorFirstnamec" for="firstnamec" class="error">error for firstname</label>

test/test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,6 +2060,37 @@ QUnit.test( "[Remote rule] #1508: Validation fails to trigger when next field is
20602060
check( "abc" );
20612061
} );
20622062

2063+
$.mockjax( {
2064+
url: "issue2150TestForm.action",
2065+
response: function() {
2066+
this.responseText = "true";
2067+
},
2068+
responseTime: 1
2069+
} );
2070+
2071+
QUnit.test( "Remote validation should not reset existing errors (#2150)", function( assert ) {
2072+
assert.expect( 3 );
2073+
var done = assert.async();
2074+
$( "#issue2150TestForm" ).validate( {
2075+
rules: {
2076+
remoteTestedInput: {
2077+
remote: "issue2150TestForm.action"
2078+
},
2079+
requiredInput: "required"
2080+
}
2081+
} );
2082+
2083+
assert.equal( $( "#requiredInput" ).attr( "class" ), undefined, "#requiredInput should not have any class" );
2084+
2085+
var isValid = $( "#issue2150TestForm" ).valid();
2086+
2087+
setTimeout( function() {
2088+
assert.equal( $( "#requiredInput" ).attr( "class" ), "error", "#requiredInput should have \"error\" class" );
2089+
assert.equal( isValid, false, "Form should have error" );
2090+
done();
2091+
} );
2092+
} );
2093+
20632094
QUnit.test( "validate checkbox on click", function( assert ) {
20642095
function errors( expected, message ) {
20652096
assert.equal( v.size(), expected, message );

0 commit comments

Comments
 (0)
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