Skip to content

HTML form action triggers on first button

I have an html form to collect all data under it. My inputs questions are hidden as default. You click their headers to make radio buttons visible (like html collapse). My problem is, i have 5 questions in the form with the same design. But when you click the question header, action triggers and goes to action’s page.

I want it to go to the action page when you click a “confirm” button that below all the questions. How can i do that?



If the question header is a <button> and is inside the form it will have a “submit” type attribute for default, so when you click it will fire the form action automatically.

You need to set the property type of all the buttons that you don’t want to be a submit button to “button”, so these will be like:

<button type="button">Wherever content that you want</button>
User contributions licensed under: CC BY-SA
2 People found this is helpful