Skip to content

Commit

Permalink
validate all onSubmit
Browse files Browse the repository at this point in the history
  • Loading branch information
elclanrs committed Oct 9, 2013
1 parent 7f76b17 commit 08e4195
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
15 changes: 10 additions & 5 deletions js/out/jquery.idealforms.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/out/jquery.idealforms.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion js/private.js
Expand Up @@ -15,6 +15,7 @@ module.exports = {

this.$form.submit(function(e) {
e.preventDefault();
self._validateAll();
self.focusFirstInvalid();
self.opts.onSubmit.call(self, self.getInvalid().length, e);
});
Expand Down Expand Up @@ -169,6 +170,10 @@ module.exports = {
this._inject('_validate', input, rule, valid);

return valid;
}
},

_validateAll: function() {
var self = this;
this.$inputs.each(function(){ self._validate(this, true) });
}
};
6 changes: 3 additions & 3 deletions js/public.js
Expand Up @@ -15,9 +15,9 @@ module.exports = {

$inputs.each(function(){ self._buildField(this) });

this.$inputs = this.$inputs
.add($inputs)
.each(function(){ self._validate(this, true) });
this.$inputs = this.$inputs.add($inputs);

this._validateAll();

this.$fields.find(this.opts.error).hide();

Expand Down

0 comments on commit 08e4195

Please sign in to comment.