Skip to content

Commit

Permalink
Core: Fix support for multiple error classes
Browse files Browse the repository at this point in the history
String#replace with a string argument replaces just once, not all matches.

Closes gh-884
  • Loading branch information
magicxie authored and jzaefferer committed Jan 14, 2014
1 parent de830b3 commit c1f0baf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ $.extend($.validator, {
},

errors: function() {
var errorClass = this.settings.errorClass.replace(" ", ".");
var errorClass = this.settings.errorClass.split(" ").join('.');
return $(this.settings.errorElement + "." + errorClass, this.errorContext);
},

Expand Down
4 changes: 3 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,14 +479,16 @@ test("option: errorClass with multiple classes", function() {
form.validate({
focusCleanup: true,
wrapper: "span",
errorClass: "error error1"
errorClass: "error error1 error2"
});
form.valid();
ok( form.is(":has(span:visible:has(label.error[for=username]))") );
ok( form.is(":has(span:visible:has(label.error1[for=username]))") );
ok( form.is(":has(span:visible:has(label.error2[for=username]))") );
$("#username").focus().trigger("focusin");
ok( !form.is(":has(span:visible:has(label.error[for=username]))") );
ok( !form.is(":has(span:visible:has(label.error1[for=username]))") );
ok( !form.is(":has(span:visible:has(label.error2[for=username]))") );
});

test("elements() order", function() {
Expand Down

0 comments on commit c1f0baf

Please sign in to comment.