ItSolutionStuff.com

JQuery Disable Submit Button on Click to Prevent Multiple Form Submits

By Hardik Savani • November 5, 2023
PHP Javascript jQuery

In this small post, we will lean how to disable button on click to prevent multiple form submits in jquery. we can stop duplicate form submission using jquery. we can easily disabled button on click event in jquery for prevent duplicate form submit.

Sometime we are working with php or any framework like laravel codeigniter and you used form with one submit button. we have form is large and big than maybe take time to submitting process so user can click many times but actual form submit again and again.

So we must have to prevent multiple form submits like prevent double click on submit button. so how we can prevent this. we can do it using jquery. when you click on submit button than it should be disabled so it's click again.

I written example for that, you can use bellow php file. you can see bellow full code. You can also check this small jquery code and full code.

$('#myFormId').submit(function(){

$("#myButtonID", this)

.html("Please Wait...")

.attr('disabled', 'disabled');

return true;

});

Here is a full example, you can see.

Example:

<!DOCTYPE html>

<html>

<head>

<title>jQuery disable submit button on click to prevent multiple form submits - ItSolutionStuff.com</title>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

</head>

<body>

<form id="myFormId">

<input type="text" name="name" placeholder="Name...">

<input type="text" name="email" placeholder="Email...">

<button type="submit" id="myButtonID">Submit</button>

</form>

<script type="text/javascript">

$('#myFormId').submit(function(){

$("#myButtonID", this)

.html("Please Wait...")

.attr('disabled', 'disabled');

return true;

});

</script>

</body>

</html>

I hope it can help you...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

JQuery Redirect to Another Page After 5 Seconds Example

Read Now →

How to Remove Empty or Null Values from JSON using JQuery?

Read Now →

How to Disable F5 Refresh Button using JQuery?

Read Now →

Add Edit Delete Table Row Example using JQuery

Read Now →

JQuery - How to Push Specific Key and Value in Array?

Read Now →

PHP MySQL Integrate Fullcalendar Example Tutorial

Read Now →

PHP Ajax Dependent Dropdown List Example

Read Now →

How to Remove Comma from String in JQuery?

Read Now →

JQuery Add Remove Input Fields Dynamically Example

Read Now →

JQuery Accordion using JQuery UI Example

Read Now →

How to Disable Right Click Menu using JQuery?

Read Now →

JQuery Draggable Sortable Table Rows Example

Read Now →

JQuery Bootbox Modal Dialog Prompt Example

Read Now →

How to Remove undefined Value from Array in JQuery?

Read Now →

How to access PHP variables in JQuery?

Read Now →