Skip to content

Commit bafc786

Browse files
bsryktjzaefferer
authored andcommitted
Fixed handling of multiple class names for errorClass option. Test by Max Lynch. Fixes jquery-validation#280
1 parent d8210bf commit bafc786

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

jquery.validate.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ $.extend($.validator, {
490490
},
491491

492492
errors: function() {
493-
return $( this.settings.errorElement + "." + this.settings.errorClass, this.errorContext );
493+
var errorClass = this.settings.errorClass.replace(' ', '.');
494+
return $( this.settings.errorElement + "." + errorClass, this.errorContext );
494495
},
495496

496497
reset: function() {

test/test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,21 @@ test("option: focusCleanup with wrapper", function() {
445445
ok( !form.is(":has(span:visible:has(label.error[for=username]))") );
446446
});
447447

448+
test("option: errorClass with multiple classes", function() {
449+
var form = $("#userForm")
450+
form.validate({
451+
focusCleanup: true,
452+
wrapper: "span",
453+
errorClass: "error error1"
454+
});
455+
form.valid();
456+
ok( form.is(":has(span:visible:has(label.error[for=username]))") );
457+
ok( form.is(":has(span:visible:has(label.error1[for=username]))") );
458+
$("#username").focus().trigger("focusin");
459+
ok( !form.is(":has(span:visible:has(label.error[for=username]))") );
460+
ok( !form.is(":has(span:visible:has(label.error1[for=username]))") );
461+
});
462+
448463
test("elements() order", function() {
449464
var container = $("#orderContainer");
450465
var v = $("#elementsOrder").validate({

0 commit comments

Comments
 (0)