Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix reset errors with "remote" validation #2150#2191

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
anufrien wants to merge9 commits intojquery-validation:master
base:master
Choose a base branch
Loading
fromanufrien:fix-reset-with-remote-validation
Open
Show file tree
Hide file tree
Changes fromall 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
19 changes: 14 additions & 5 deletionssrc/core.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -912,9 +912,16 @@ $.extend( $.validator, {
},

invalidElements: function() {
return $( this.errorList ).map( function() {
return this.element;
var
v = this,
invalid = $.extend( {}, v.invalid ),
$elements = $( [] );
$.each( invalid, function( key, value ) {
if ( value !== false && invalid.hasOwnProperty( key ) ) {
$elements = $elements.add( v.findByName( key ) );
}
} );
return $elements;
},

showLabel: function( element, message ) {
Expand DownExpand Up@@ -1532,7 +1539,7 @@ $.extend( $.validator, {
method = typeof method === "string" && method || "remote";

var previous = this.previousValue( element, method ),
validator, data, optionDataString;
validator, data, optionDataString, result = "pending";

if ( !this.settings.messages[ element.name ] ) {
this.settings.messages[ element.name ] = {};
Expand DownExpand Up@@ -1577,11 +1584,13 @@ $.extend( $.validator, {
validator.invalid[ element.name ] = true;
validator.showErrors( errors );
}
previous.valid = valid;

// Fix for QUnit test "remote" method with ajax immediate callback
result = previous.valid = valid;
validator.stopRequest( element, valid );
}
}, param ) );
return"pending";
returnresult;
}
}

Expand Down
2 changes: 1 addition & 1 deletiontest/methods.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -708,7 +708,7 @@ QUnit.test( "remote, highlight all invalid fields", function( assert ) {
}, 500 );
} );
QUnit.test( "remote, unhighlighted should be invoked after being highlighted/invalid", function( assert ) {
assert.expect(6 );
assert.expect(7 );

var done1 = assert.async(),
done2 = assert.async(),
Expand Down
4 changes: 2 additions & 2 deletionstest/rules.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -374,10 +374,10 @@ QUnit.test( "rules(), global/local normalizer", function( assert ) {

// Validate only the username and the url elements.
username.valid();
assert.equal( v.invalidElements()[ 0 ], username[ 0 ], "The username should be invalid" );
assert.equal( v.invalidElements().filter( username )[ 0 ], username[ 0 ], "The username should be invalid" );

urlc.valid();
assert.equal( v.invalidElements()[ 0 ], urlc[ 0 ], "The url should be invalid" );
assert.equal( v.invalidElements().filter( urlc )[ 0 ], urlc[ 0 ], "The url should be invalid" );

assert.equal( v.numberOfInvalids(), 2, "There is two invalid elements" );

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp