{"id":42,"date":"2006-01-26T10:05:12","date_gmt":"2006-01-26T15:05:12","guid":{"rendered":"http:\/\/pessoal.org\/blog\/?p=42"},"modified":"2006-01-26T11:35:25","modified_gmt":"2006-01-26T16:35:25","slug":"form-inputs-and-their-behaviors","status":"publish","type":"post","link":"https:\/\/pessoal.org\/blog\/2006\/01\/26\/form-inputs-and-their-behaviors\/","title":{"rendered":"Form inputs and their behaviors"},"content":{"rendered":"<p>So looks like someone needs to play a bit more with their form inputs. <a href=\"http:\/\/markos.gaivo.net\/blog\/?p=109\">Marko reports<\/a> that when he changed his form from:<\/p>\n<p><code>&lt;input type=\"button\" \/&gt;<\/code><\/p>\n<p>to:<\/p>\n<p><code>&lt;input type=\"image\" \/&gt;<\/code><\/p>\n<p>His forms started getting submitted automatically when clicking the image button. But yeah, that&#8217;s how it&#8217;s supposed to work. If that button is supposed to be your main &#8220;submit&#8221; like button on your form, then change your JavaScript code to trap the onSubmit event and return false to it. As in:<\/p>\n<p><code>&lt;form method=\"post\" onSubmit=\"javascript:return handleXHR();\"&gt;&lt;\/form&gt;<\/code><\/p>\n<p>Then inside that function you just do &#8220;return false;&#8221; to stop the form from being submitted.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So looks like someone needs to play a bit more with their form inputs. Marko reports that when he changed his form from: &lt;input type=&#8221;button&#8221; \/&gt; to: &lt;input type=&#8221;image&#8221; \/&gt; His forms started getting submitted automatically when clicking the image button. But yeah, that&#8217;s how it&#8217;s supposed to work. If that button is supposed to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"_links":{"self":[{"href":"https:\/\/pessoal.org\/blog\/wp-json\/wp\/v2\/posts\/42"}],"collection":[{"href":"https:\/\/pessoal.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pessoal.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pessoal.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pessoal.org\/blog\/wp-json\/wp\/v2\/comments?post=42"}],"version-history":[{"count":0,"href":"https:\/\/pessoal.org\/blog\/wp-json\/wp\/v2\/posts\/42\/revisions"}],"wp:attachment":[{"href":"https:\/\/pessoal.org\/blog\/wp-json\/wp\/v2\/media?parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pessoal.org\/blog\/wp-json\/wp\/v2\/categories?post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pessoal.org\/blog\/wp-json\/wp\/v2\/tags?post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}