0

I'm trying to solve a double submission problem in my application. This happens when an impatient user hit the button more than once, the action is carried out severally.

@if($purchase->state == 1)
    <form action="{{route('confirm',['uniqueid'=>$purchase->uniqueid])}}" method="post">
        {{csrf_field()}}
        <button type="submit" name="button" class="btn btn-danger btn-xs">Complete</button>
    </form>
@endif
Roman Meyer
  • 2,634
  • 2
  • 20
  • 27
Sammy
  • 45
  • 7

1 Answers1

0

try this.

<input id="submitButton" type="button" value="Submit" onclick="submitForm(this);" />

<script>
    function submitForm(btn) {
        // disable the button
        btn.disabled = true;
        // submit the form    
        btn.form.submit();
    }
</script>
fahim152
  • 2,531
  • 1
  • 10
  • 29