Form is not submitting to chrome, but in firefox post

I have a submit button, for example:

Save and continue

And My function in js:

function checkCreditDebit(buttonValues) {
    //Some validation here

   //Disable Button if once clicked to prevent twice form submission
    document.getElementById('saveandcontinue').disabled = 'disabled';
    document.getElementById('onlysave').disabled = 'disabled';

}

      

But when I submit the form in firefox it turned off the "save and continue" button and submit the form. But in chrome disable the button but don't submit the form. What is wrong with this, please suggest. Thanks in Advance

+3


source to share


3 answers


    instead of disabling pervent multiple submit by setting a javascript flag example : 
    <form method="post" id="ecomFormBean" name="ecomFormBean" onsubmit="return checkSubmit(this);" >
 <input type="text" />
    <input type="submit" />
</form>
    <script>
    var formSubmitted = false;
    function checkSubmit(f){
        if (formSubmitted) {
          alert('Please be patient. Your order may take 10 - 15 seconds to process. Thank you!');
          return false;
        }
        else return formSubmitted = true;
    }

    </script>

      



-1


source


Rather than just disable the submit button (forms can also be submitted if you press enter in the text boxes) attach a handler to your form that will leave the "class name" in your form as a mark already submitted if the user is again will submit the form, the handler should check if the form already has a class name and then prevent duplicate submissions via event.preventDefault ().

try this:



<form onsubmit="prevent_duplicate(event,this);" action="">
    <input type="text" />
    <input type="submit" />
</form>
<script>
    function prevent_duplicate(event,form)
    {
       if((" "+form.className+" ").indexOf(" submitted ") > -1)
       {
          alert("can't submit more than once!!!");
          event.preventDefault();
       }
       else
       {
           form.classList.add("submitted");
       }
   }
</script>

      

Demo here

+6


source


Chrome is very fast with javascript. So it is possible that your checkCreditDebit (buttonValues) function, which should disable the submit button, is executed before your php script submits the form.

I suggest you call the setTimeOut function before calling the javascript function so that the form can be submitted.

Try it.

-1


source







All Articles