{"id":2767,"date":"2023-07-06T11:10:38","date_gmt":"2023-07-06T09:10:38","guid":{"rendered":"https:\/\/nguenkam.com\/blog\/?p=2767"},"modified":"2023-07-06T11:15:15","modified_gmt":"2023-07-06T09:15:15","slug":"how-to-ensure-that-only-one-button-performs-the-submit-function-in-form","status":"publish","type":"post","link":"https:\/\/nguenkam.com\/blog\/index.php\/2023\/07\/06\/how-to-ensure-that-only-one-button-performs-the-submit-function-in-form\/","title":{"rendered":"How to ensure that only one button performs the submit function in form."},"content":{"rendered":"\n<p>To ensure that only one button performs the submit function, you can set the other button&#8217;s type attribute value to &#8220;button&#8221;. This prevents the other button from submitting the form. Here is an example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;form (ngSubmit)=\"onSubmit()\"&gt; \n  &lt;!-- Button that submits the form --&gt;\n  &lt;button type=\"submit\"&gt;Submit&lt;\/button&gt;\n\n  &lt;!-- Button that has no submit function --&gt;\n  &lt;button type=\"button\"&gt;Nicht senden&lt;\/button&gt;\n&lt;\/form&gt;\n<\/code><\/pre>\n\n\n\n<p>Adding type=&#8221;button&#8221; to the second button prevents it from submitting the form. Instead, it can be used for other actions, such as resetting the form or cancel, or..or&#8230;or&#8230; \ud83d\ude42 .<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To ensure that only one button performs the submit function, you can set the other button&#8217;s type attribute value to &#8220;button&#8221;. This prevents the other button from submitting the form. Here is an example: Adding type=&#8221;button&#8221; to the second button prevents it from submitting the form. Instead, it can be used for other actions, such [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2769,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[702],"tags":[703,704],"_links":{"self":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2767"}],"collection":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=2767"}],"version-history":[{"count":2,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2767\/revisions"}],"predecessor-version":[{"id":2770,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2767\/revisions\/2770"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media\/2769"}],"wp:attachment":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=2767"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=2767"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=2767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}