I have this form declaration:
<form method="post" action="/web_services/buscar_vuelos?method=get"> <div id="addSegment_wrapper"> <button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" id="addTr" style="display: inline;"> <span class="ui-button-text">Add Segment</span> </button> </div> <input id="web_services_submit" class="ui-button ui-widget ui-state-default ui-corner-all ui-button- text-only" type="submit" value="Search" name="commit"> </form>
And, although I didn't specify "addSegment_wrapper" button as a submit one, every time I click on it, it calls the form action. I just want to treat this button as a regular one.
What should I do?
Set it to type="button" to produce a button that doesn't submit the form. In the words of the HTML Standard: "Does nothing."
The simplest solution to prevent the form submission is to return false on submit event handler defined using the onsubmit property in the HTML <form> element.
Yes, structurally the submit button needs to be inside a form element for the document to be valid X/HTML.
In HTML, <input type="button" /> is used to create buttons in an HTML form. Inside the <button> tag, you can place content like text or images. However, this is not the case with the buttons created with <input> tag. The button element has type=button as default outside the form.
You could do
<button type="button">Add Segment</button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With