Today I had an simple task: to disable a button after a click to prevent double submitting the form data. I wanted to solve it as simple as possible. So here’s the final solution
<form method="POST" action=""> <input type="submit" value="Submit" name="submitBtn" onclick="this.disabled=true;this.form.submit();" > </form>
It works like a charm – it disables the submit button and it submits the data.
I have found a interesting bug in Chrome. My input button had its name set to “submit” (name=”submit”), but then chrome was reporting following error:
Uncaught TypeError: Property 'submit' of object #<HTMLFormElement> is not a function generate-form.php:onclick