Skip to content

Commit

Permalink
terminate the loop sooner
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeraj Singh committed Apr 18, 2011
1 parent 23a6668 commit 818c975
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/rails.js
Expand Up @@ -151,7 +151,10 @@
var blankExists = false,
selector = specifiedSelector || 'input';
form.find(selector).each(function() {
if (!$(this).val()) blankExists = true;
if (!$(this).val()) {
blankExists = true;
return false; //this terminates the each loop
}
});
return blankExists;
},
Expand All @@ -160,7 +163,10 @@
var nonBlankExists = false,
selector = specifiedSelector || 'input';
form.find(selector).each(function() {
if ($(this).val()) nonBlankExists = true;
if ($(this).val()) {
nonBlankExists = true;
return false; //this terminates the each loop
}
});
return nonBlankExists;
},
Expand Down

0 comments on commit 818c975

Please sign in to comment.