I have a form like this:
<form action="lol.php" method="POST">
<input type="text" name="fe" />
<input type="submit" id="submitbtn" value="submit" onclick="this.disabled = true;" />
</form>
and in Firefox it works perfectly, but in Internet Explorer (latest version) the button becomes disabled but the form does not submit. I have also tried:
<form action="lol.php" method="POST" onsubmit="document.getElementById('submitbtn').disabled = true">
and removed the onclick code from the submit button, but that had the same effect. What code should I use so that it works on all browsers?
Ok, so the good hack is to prepare second fake button that does nothing:
<form action="lol.php" method="POST">
<input type="text" name="fe" />
<input type="button" id="submitbtnDisabled" disabled="disabled" value="submit" style="display:none;" />
<input type="submit" id="submitbtn" value="submit" onclick="this.style.display='none'; document.getElementById('submitbtnDisabled').style.display='inline';" />
</form>
Note:
Because you said you're not using jQuery I'm using standard JavaScript. The only suggestion is to use unbotrusive JavaScript and move inline CSS to a stylesheet just to separate scripts and styles from HTML.
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