I have a form with 2 buttons
<a href="index.html"><button>Cancel changes</button></a> <button type="submit">Submit</button>
I also used jQuery UI buttons on them, like this
$('button').button();
However, the first button also submits the form. I originally thought it wouldn't happen without type="submit"
.
Obviously I can do it
$('button[type!=submit]').click(function(event) { event.stopPropagation(); });
But is there a way to prevent the back button from submitting the form without JavaScript intervention?
To be honest, I just used a button so I could style it using jQuery UI. I tried calling button()
on the link but it didn't work as expected (looked ugly!).
button
The default type of element a> issubmit
.You can make it do nothing by setting the
button
type:The default value of the
typebutton
element's /code> attribute is "submit". Set this totype="button"
to generate a button that does not submit the form.Using HTML standard words: "Do nothing."