How to Disable Submit Button After Form Submission in PHP?




How to Disable Submit Button After Form Submission in PHP?

How to Disable Submit Button After Form Submission in PHP?

I will help you for how to disable submit button after click in jquery php. we can prevent double click submit button in jquery html. it will help you to disable submit button after click in php, laravel, codeigniter etc project that use jquery.

Sometime, we have to prevent too many clicks on submit button. if you are working on register form with php then it might be take time to submit form because of long processes of submit page. But if user have server issue or Internet issue etc then he will just click again and again. So may it can create problem form us. so basically you must prevent it by using disabled submit button after one click using jquery.

Also Read:- How to Add Spell Checker In Your Webpage Using jQuery

Here bellow simple example will help you to resolved your problem by using bellow example. You can see full example so it can help you in your php project.

<!DOCTYPE html>
<html>
   <head>
      <title>How to Disable Submit Button After Form Submission in PHP?</title>
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
   </head>
   <body>
      <form action="/post.php" method="POST" id="my-form">
         <input type="text" name="name">
         <input type="text" name="email">
         <button type="submit" id="btn-submit">Submit</button>
      </form>
      <script type="text/javascript">
         $(document).ready(function () {
         
             $("#my-form").submit(function (e) {
                 $("#btn-submit").attr("disabled", true);
                 return true;
         
             });
         });
         
      </script>
   </body>
</html>

 


Author Biography.

Lokesh Gupta
Lokesh Gupta

Overall 3+ years of experience as a Full Stack Developer with a demonstrated history of working in the information technology and services industry. I enjoy solving complex problems within budget and deadlines putting my skills on PHP, MySQL, Python, Codeigniter, Yii2, Laravel, AngularJS, ReactJS, NodeJS to best use. Through Knowledge of UML & visual modeling, application architecture design & business process modeling. Successfully delivered various projects, based on different technologies across the globe.



News & Blogs

06df58ced4c8c6bd7e387d3cd0d4167f.png

Top React.js tools for Developers

React continues to grow in popularity by almost 150% from 2017 to 2018. This ...

04dd32c0108d23bf51249aeab490ad84.png

Get a head start with trending Nodejs developer...

To build and run applications, you need different types of runtime environments that help in seve...

99c65279a4f62ad85fb5b8b340077bb3.png

How to Integrate Payumoney Payment Gateway in L...

I am going to explain How to Integrate Payumoney Payment Gateway in Laravel 5. Most of thing are ...