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 bees 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?
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 bees 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?
Share Improve this question edited Dec 1, 2010 at 2:47 Tim Stone 19.2k6 gold badges57 silver badges66 bronze badges asked Aug 3, 2010 at 2:36 fitzfitz 413 bronze badges5 Answers
Reset to default 5Ok, 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.
I ran into this problem before as well. I ended up hiding the submit button when the form was submitted, and replacing it with a disabled button with the same text. Worked great.
That's weird.
Try:
<input type="submit" id="submitbtn" value="submit" onclick="setTimeout(function () { this.disabled = true;}, 0)" />
Try this:
onclick="this.disabled=true;return true;"
Otherwise, MS explorer is not allowing the button to continue processing once disabled.
If you want you can use jquery.
Try this:
$('#submtbtn').submit(function() {
$(this).attr('disabled', 'disabled');
});
I think it works on all browser.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744179243a4561903.html
评论列表(0条)