Skip to content

Commit

Permalink
Core: resetForm should also remove valid class from elements
Browse files Browse the repository at this point in the history
Closes #1708
  • Loading branch information
Arkni authored and staabm committed Feb 24, 2016
1 parent e9fd71d commit f07a267
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core.js
Expand Up @@ -529,9 +529,12 @@ $.extend( $.validator, {
for ( i = 0; elements[ i ]; i++ ) {
this.settings.unhighlight.call( this, elements[ i ],
this.settings.errorClass, "" );
this.findByName( elements[ i ].name ).removeClass( this.settings.validClass );
}
} else {
elements.removeClass( this.settings.errorClass );
elements
.removeClass( this.settings.errorClass )
.removeClass( this.settings.validClass );
}
},

Expand Down
2 changes: 2 additions & 0 deletions test/test.js
Expand Up @@ -976,10 +976,12 @@ test( "resetForm()", function() {
v.form();
errors( 2 );
ok( $( "#firstname" ).hasClass( "error" ) );
ok( $( "#something" ).hasClass( "valid" ) );
$( "#firstname" ).val( "hiy" );
v.resetForm();
errors( 0 );
ok( !$( "#firstname" ).hasClass( "error" ) );
ok( !$( "#something" ).hasClass( "valid" ) );
equal( $( "#firstname" ).val(), "", "form plugin is included, therefor resetForm must also reset inputs, not only errors" );
} );

Expand Down

0 comments on commit f07a267

Please sign in to comment.