Skip to content

Commit

Permalink
valid(): Check all elements. Fixes #791 - valid() validates only the …
Browse files Browse the repository at this point in the history
…first (invalid) element
  • Loading branch information
jzaefferer committed Jun 24, 2013
1 parent 1b08c8c commit 6f26803
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ $.extend($.fn, {
var valid = true;
var validator = $(this[0].form).validate();
this.each(function() {
valid = valid && validator.element(this);
valid = validator.element(this) && valid;
});
return valid;
}
Expand Down
7 changes: 4 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ test("valid() plugin method", function() {
ok ( input.valid(), "Input is valid, too" );
});

test("valid() plugin method", function() {
test("valid() plugin method, multiple inputs", function() {
var form = $("#testForm1");
form.validate();
var validator = form.validate();
var inputs = form.find("input");
ok( !inputs.valid(), "all invalid" );
inputs.not(":first").val("ok");
equal( validator.numberOfInvalids(), 2 );
strictEqual( inputs.valid(), false, "just one invalid" );
inputs.val("ok");
strictEqual( inputs.valid(), true, "all valid" );
Expand Down Expand Up @@ -1492,7 +1493,7 @@ test("Min and Max type absent set by attributes valid", function() {

test("Min and Max range set by attributes valid", function() {
//
// cannot test for overflow:
// cannot test for overflow:
// When the element is suffering from an underflow,
// the user agent must set the element's value to a valid
// floating-point number that represents the minimum.
Expand Down

0 comments on commit 6f26803

Please sign in to comment.