8000 Core: Call to resetInternals removed in remote validation callback by leonardospina · Pull Request #2242 · jquery-validation/jquery-validation · GitHub
[go: up one dir, main page]

Skip to content

Core: Call to resetInternals removed in remote validation callback #2242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,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 );
Expand Down
4 changes: 4 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ <h2 id="qunit-userAgent"></h2>
<input type="text" data-rule-required="true" title="buga" name="lastname" id="lastname">
<input type="text" data-rule-required="true" title="something" name="something" id="something" value="something">
</form>
<form id="issue2150TestForm">
<input id="remoteTestedInput" type="text" name="remoteTestedInput" value="test" /><br/>
<input id="requiredInput" type="text" name="requiredInput" value="" />
</form>
<form id="testForm1clean">
<input title="buga" name="firstnamec" id="firstnamec">
<label id="errorFirstnamec" for="firstnamec" class="error">error for firstname</label>
Expand Down
31 changes: 31 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2060,6 +2060,37 @@ 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 );
Expand Down
0