I would like to have a function to add an onclick event to my form buttons to get them disabled in order to avoid double posting.
<form>
<button onclick="disable(this)" type="submit">post</button>
</form>
<script> function disable(button){ $(button). ??? }</script>
Ani idea or tip? thanks!
The button must be an
inputelement (if you don’t submit the form via JavaScript). A<button>element has no attributetypeand setting it will have no effect.I also suggest to attach the
clickhandler via jQuery:Reference:
click,attr