Update main.js

This commit is contained in:
Reinier Guerra 2015-07-09 23:32:23 -04:00
parent b86cca70b3
commit 8691866c0d
1 changed files with 4 additions and 3 deletions

View File

@ -365,17 +365,18 @@ Formsy.Form = React.createClass({
// Validate the form by going through all child input components
// and check their state
validateForm: function () {
var allIsValid = true;
var allIsValid;
var inputs = this.inputs;
var inputKeys = Object.keys(inputs);
// We need a callback as we are validating all inputs again. This will
// run when the last component has set its state
var onValidationComplete = function () {
inputKeys.forEach(function (name) {
allIsValid = inputKeys.every(function (name) {
if (!inputs[name].state._isValid) {
allIsValid = false;
return false;
}
return true;
}.bind(this));
this.setState({