From 8691866c0dd3c8d956931e186f43c73e1aa8aafa Mon Sep 17 00:00:00 2001 From: Reinier Guerra Date: Thu, 9 Jul 2015 23:32:23 -0400 Subject: [PATCH 1/2] Update main.js --- src/main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index 7689b99..ff14fc6 100644 --- a/src/main.js +++ b/src/main.js @@ -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({ From 31e959017228f934548df14378aab8b3bee77fec Mon Sep 17 00:00:00 2001 From: Reinier Guerra Date: Fri, 10 Jul 2015 11:18:44 -0400 Subject: [PATCH 2/2] Update main.js --- src/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main.js b/src/main.js index ff14fc6..729d3f5 100644 --- a/src/main.js +++ b/src/main.js @@ -373,10 +373,7 @@ Formsy.Form = React.createClass({ // run when the last component has set its state var onValidationComplete = function () { allIsValid = inputKeys.every(function (name) { - if (!inputs[name].state._isValid) { - return false; - } - return true; + return inputs[name].state._isValid; }.bind(this)); this.setState({