Skip to content

Commit a856823

Browse files
mlynchjzaefferer
authored andcommitted
Add element to success call with test. Fixes jquery-validation#60
1 parent 851e941 commit a856823

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

jquery.validate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ $.extend($.validator, {
703703
if ( typeof this.settings.success === "string" ) {
704704
label.addClass( this.settings.success );
705705
} else {
706-
this.settings.success( label );
706+
this.settings.success( label, element );
707707
}
708708
}
709709
this.toShow = this.toShow.add(label);

test/test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,17 @@ test("success isn't called for optional elements", function() {
875875
equal( 0, $("#testForm1 label").size() );
876876
});
877877

878+
test("success callback with element", function() {
879+
expect(1);
880+
var v = $("#userForm").validate({
881+
success: function( label, element ) {
882+
equal( element, $('#username').get(0) );
883+
}
884+
});
885+
$("#username").val("hi");
886+
v.form();
887+
});
888+
878889
test("all rules are evaluated even if one returns a dependency-mistmatch", function() {
879890
expect(6);
880891
equal( "", $("#firstname").removeClass().val() );

0 commit comments

Comments
 (0)