Permalink
Browse files

Fixed handling of multiple class names for errorClass option. Test by…

… Max Lynch. Fixes #280
  • Loading branch information...
1 parent d8210bf commit bafc78671a948355b75c57d7e90bd299d485debe @bsrykt bsrykt committed with jzaefferer Dec 9, 2011
Showing with 17 additions and 1 deletion.
  1. +2 −1 jquery.validate.js
  2. +15 −0 test/test.js
View
3 jquery.validate.js
@@ -490,7 +490,8 @@ $.extend($.validator, {
},
errors: function() {
- return $( this.settings.errorElement + "." + this.settings.errorClass, this.errorContext );
+ var errorClass = this.settings.errorClass.replace(' ', '.');
+ return $( this.settings.errorElement + "." + errorClass, this.errorContext );
},
reset: function() {
View
15 test/test.js
@@ -445,6 +445,21 @@ test("option: focusCleanup with wrapper", function() {
ok( !form.is(":has(span:visible:has(label.error[for=username]))") );
});
+test("option: errorClass with multiple classes", function() {
+ var form = $("#userForm")
+ form.validate({
+ focusCleanup: true,
+ wrapper: "span",
+ errorClass: "error error1"
+ });
+ form.valid();
+ ok( form.is(":has(span:visible:has(label.error[for=username]))") );
+ ok( form.is(":has(span:visible:has(label.error1[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]))") );
+});
+
test("elements() order", function() {
var container = $("#orderContainer");
var v = $("#elementsOrder").validate({

0 comments on commit bafc786

Please sign in to comment.