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({