For preventing the submit button's double click, I wrote the following function which is called on the form's onsubmit event.

<script language="JavaScript">
var submitFlag = false;
function checkForm(){
    if ( submitFlag == false ) {
        submitFlag = true;
        return true;
    } else {
        alert('double click');
        return false;
    }
}
</script>
<form name="f1" method="post" action="B.jsp" onSubmit="return checkForm()">

In Internet Explorer, when I click the submit button twice, alert method occurs. If I don't click the okay button in the alert box, the jsp isn't redirected.

However in Firefox, the alert box is very fast, I have no time to click the ok button. The jsp is redirected very fast, and the second request has been sent out.

How can I block the request from going through in Firefox?

link|improve this question
a bit premature with the banhammer imo... you should ask this question on stackoverflow stackoverflow.com as it's more within the scope of that site. – jammypeach Nov 3 '11 at 10:16
feedback

closed as off topic by Gareth, Sathya Nov 3 '11 at 9:37

Questions on Super User are expected to generally relate to computer software or computer hardware, within the scope defined in the faq.

Browse other questions tagged or ask your own question.