You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<divclass="app___3P8ep hasNav___1KF_W"><divclass="nav___11xa5"><buttontype="button"></button><divclass="overlay___1GMox"><iclass="fa fa-times"></i> Close</div><divclass="placeholder___TzF1K"></div><navclass="menu___12xDU"><ahref="https://redux-form.com/7.4.2" class="brand___1qRUu">Redux Form</a><div><divid="codefund_ad" class="benevolent-sponsor template-image-only" style="min-height:211px"></div></div><ahref="https://redux-form.com/7.4.2/docs/GettingStarted.md" class="">Getting Started</a><ahref="https://redux-form.com/7.4.2/docs/MigrationGuide.md" class=""><code>v6</code> Migration Guide</a><ahref="https://redux-form.com/7.4.2/docs/ValueLifecycle.md" class="">Value Lifecycle</a><ahref="https://redux-form.com/7.4.2/docs/Flow.md" class="">Flow</a><ahref="https://redux-form.com/7.4.2/docs/api" class="">API</a><ahref="https://redux-form.com/7.4.2/docs/api/ReduxForm.md" class="indent1___4iVnL"><code>reduxForm()</code></a><ahref="https://redux-form.com/7.4.2/docs/api/Props.md" class="indent1___4iVnL"><code>props</code></a><ahref="https://redux-form.com/7.4.2/docs/api/Field.md" class="indent1___4iVnL"><code>Field</code></a><ahref="https://redux-form.com/7.4.2/docs/api/Fields.md" class="indent1___4iVnL"><code>Fields</code></a><ahref="https://redux-form.com/7.4.2/docs/api/FieldArray.md" class="indent1___4iVnL"><code>FieldArray</code></a><ahref="https://redux-form.com/7.4.2/docs/api/Form.md" class="indent1___4iVnL"><code>Form</code></a><ahref="https://redux-form.com/7.4.2/docs/api/FormName.md" class="indent1___4iVnL"><code>FormName</code></a><ahref="https://redux-form.com/7.4.2/docs/api/FormSection.md" class="indent1___4iVnL"><code>FormSection</code></a><ahref="https://redux-form.com/7.4.2/docs/api/FormValues.md" class="indent1___4iVnL"><code>formValues()</code></a><ahref="https://redux-form.com/7.4.2/docs/api/FormValueSelector.md" class="indent1___4iVnL"><code>formValueSelector()</code></a><ahref="https://redux-form.com/7.4.2/docs/api/Reducer.md" class="indent1___4iVnL"><code>reducer</code></a><ahref="https://redux-form.com/7.4.2/docs/api/ReducerPlugin.md" class="indent2___2PiOO"><code>reducer.plugin()</code></a><ahref="https://redux-form.com/7.4.2/docs/api/SubmissionError.md" class="indent1___4iVnL"><code>SubmissionError</code></a><ahref="https://redux-form.com/7.4.2/docs/api/ActionCreators.md" class="indent1___4iVnL">Action Creators</a><ahref="https://redux-form.com/7.4.2/docs/api/Selectors.md" class="indent1___4iVnL">Selectors</a><ahref="https://redux-form.com/7.4.2/docs/faq" class="">FAQ</a><ahref="https://redux-form.com/7.4.2/examples" class="">Examples</a><ahref="https://redux-form.com/7.4.2/examples/simple" class="indent1___4iVnL">Simple Form</a><ahref="https://redux-form.com/7.4.2/examples/syncValidation" class="indent1___4iVnL">Sync Validation</a><ahref="https://redux-form.com/7.4.2/examples/fieldLevelValidation" class="indent1___4iVnL">Field-Level Validation</a><ahref="https://redux-form.com/7.4.2/examples/submitValidation" class="indent1___4iVnL">Submit Validation</a><ahref="https://redux-form.com/7.4.2/examples/asyncValidation" class="indent1___4iVnL">Async Blur Validation</a><ahref="https://redux-form.com/7.4.2/examples/asyncChangeValidation" class="indent1___4iVnL">Async Change Validation</a><ahref="https://redux-form.com/7.4.2/examples/initializeFromState" class="indent1___4iVnL">Initializing from State</a><ahref="https://redux-form.com/7.4.2/examples/selectingFormValues" class="indent1___4iVnL">Selecting Form Values</a><ahref="https://redux-form.com/7.4.2/examples/fieldArrays" class="indent1___4iVnL">Field Arrays</a><ahref="https://redux-form.com/7.4.2/examples/remoteSubmit" class="indent1___4iVnL">Remote Submit</a><ahref="https://redux-form.com/7.4.2/examples/normalizing" class="indent1___4iVnL">Normalizing</a><ahref="https://redux-form.com/7.4.2/examples/immutable" class="indent1___4iVnL">Immutable JS</a><ahref="https://redux-form.com/7.4.2/examples/wizard" class="indent1___4iVnL">Wizard Form</a><ahref="https://redux-form.com/7.4.2/examples/material-ui" class="indent1___4iVnL">Material UI</a><ahref="https://redux-form.com/7.4.2/examples/react-widgets" class="indent1___4iVnL">React Widgets</a><ahref="https://redux-form.com/7.4.2/docs/DocumentationVersions.md" class="">Older Versions</a></nav></div><divclass="contentAndFooter___kE2nt"><divclass="topNav___sBW8S"><ahref="https://redux-form.com" class="brand___YAZl-"></a><aclass="github___3-vRv" href="https://github.com/erikras/redux-form" title="Github" target="_blank"><iclass="fa fa-fw fa-github"></i></a></div><divclass="content___3TVHp"><div><olclass="breadcrumbs___1BHo6"><li><ahref="https://redux-form.com/7.4.2/">Redux Form</a></li><li><ahref="https://redux-form.com/7.4.2/docs/faq">FAQ</a></li><li>Why are all my buttons triggering onSubmit?</li></ol><div><h1class="heading___2W8-L" id="why-are-all-my-buttons-triggering-code-onsubmit-code-">Why are all my buttons triggering <code>onSubmit</code>? <ahref="#why-are-all-my-buttons-triggering-code-onsubmit-code-" class="anchor___j3LpN">#</a></h1><p>You may want to add a 'reset' or 'cancel' button to your form. When doing so, be wary of the <code>type</code> property passed to your <code><button/></code>. This can cause all buttons within your form to trigger <code>onSubmit</code>.</p>
28
+
<p><code><button/></code> elements are automatically associated with parent <code><form/></code> elements:</p>
29
+
<blockquote>
30
+
<p>If <em>[the <code>form</code> property]</em> is not specified, the <code><button></code> element will be associated to an ancestor <code><form></code> element, if one exists.</p>
31
+
</blockquote>
32
+
<p>The default <code>type</code> property assigned to <code><button/></code> elements is <code>submit</code>. This causes the button to attempt to trigger their parent form's <code>onSubmit</code> handler, regardless of the button's own click handler. By changing <code>type</code> to <code>button</code>, your button will trigger your passed event handler instead of trying to submit the form.</p>
33
+
<p>For more information, refer to the <ahref="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button">MDN documentation</a>.</p>
34
+
</div></div></div><divclass="footer___1oh0h"><div>Created by Erik Rasmussen</div><div>Got questions? Ask for help:<aclass="help___3OayI" href="https://stackoverflow.com/questions/ask?tags=redux-form" title="Stack Overflow" target="_blank"><iclass="fa fa-fw fa-stack-overflow"></i></a><aclass="help___3OayI" href="https://github.com/erikras/redux-form/issues/new" title="Github" target="_blank"><iclass="fa fa-fw fa-github"></i></a></div><div><ahref="https://twitter.com/erikras" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @erikras</a><ahref="https://twitter.com/ReduxForm" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @ReduxForm</a></div></div></div></div>
<script>initReact({"version":"7.4.2","path":"/docs/faq/ButtonType.md","breadcrumbs":[{"path":"https://redux-form.com/7.4.2/","title":"Redux Form"},{"path":"https://redux-form.com/7.4.2/docs/faq","title":"FAQ"},{"path":"https://redux-form.com/7.4.2/docs/faq/ButtonType.md","title":"Why are all my buttons triggering onSubmit?"}]})</script>
0 commit comments