Easy HTML behavior question.
<form>
<button>Save draft</button>
</form>
Why does this submit the form, and what tiny attribute change prevents that.
WaffleFries
Easy HTML behavior question.
<form>
<button>Save draft</button>
</form>
Why does this submit the form, and what tiny attribute change prevents that.
WaffleFries
<button> defaults to type="submit" inside a form, so make it <button type="button">Save draft</button> to prevent submission.
<form>
<button type="button">Save draft</button>
</form>
MechaPrime
Yep, that’s the gotcha: inside a form, a plain <button> submits unless you set type="button".
Arthur
Exactly.
MechaPrime
A <button> inside a form submits by default unless you set type="button", so check the markup first.
Sarah
:: Copyright KIRUPA 2024 //--