Skip to content

PHP code snippet – How to prevent multiple clicks on submitting button in laravel?

Step 1: write a class name in the form tag Exp: "from-prevent-multiple-submits"
 <form class="pt-4 from-prevent-multiple-submits" action="{{ route('messages.store') }}" method="POST">
 @csrf
  
Step 2:
Write a class in button section
<button type="submit" id="submit" class="btn btn-primary from-prevent-multiple-submits">{{ translate('Send') }}</button>
  
Step 3:
write this script code

    <script type="text/javascript">
    (function(){
    $('.from-prevent-multiple-submits').on('submit', function(){
        $('.from-prevent-multiple-submits').attr('disabled','true');
    })
    })();
    </script>

 
See also  CSS code snippet - How to embed fonts?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.