Tagged: jquery disable button after click

jQuery Enable Disable Submit Button Example 0

jQuery Enable Disable Submit Button Example

Today, We want to share with you jQuery Enable Disable Submit Button Example.In this post we will show you How to enable and disable submit button using jQuery, hear for jQuery – How to disabled submit button after clicked we will give you demo and example for implement.In this post, we will learn about Disable or Enable Submit Button using jQuery .prop() Method with an example.

jQuery Enable Disable Submit Button Example

There are the Following The simple About jQuery Enable Disable Submit Button Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop Enable Disable Submit Button using jQuery, so the some how to enable and disable submit button in php for this example is following below.

Example 1: Enable Or Disable Submit Button Using Jquery

$(document).ready(function() {
     $(':input[type="submit"]').prop('disabled', true);
     $('input[type="text"]').keyup(function() {
        if($(this).val() != '') {
           $(':input[type="submit"]').prop('disabled', false);
        }
     });
 });

Example 2 : Enable Disable Submit Button Based on Validation

<input type="text" name="textTitle" name="suggestion_title" id="suggestion_title" value="" placeholder="Your title" required="" pattern=".{10,100}" maxlength="100" title="Title must be between 10 and 100 characters."/>
<input type="submit" value="send" />

$('input[type="submit"]').attr('disabled', true);
$('input[type="text"]').on('keyup',function() {
    if($(this).val() != '') {
        $('input[type="submit"]').attr('disabled' , false);
    }else{
        $('input[type="submit"]').attr('disabled' , true);
    }
});

Example 3 : enable/disable an element using jQuery

$(function() {
  $(":text").keypress(submitbtn).each(function() {
    submitbtn();
  });
});

function submitbtn() {
  if ($(this).val().length == 0) {
    $(":submit").attr("disabled", true);
  } else {
    $(":submit").removeAttr("disabled");
  }
}

Example 4 : jQuery Disable/Enable button in form

<!DOCTYPE html>
<html>
<head>
<title>Disable a button dynamically created</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
    $('#textTitle').click(function() {
        $(this).prop('disabled',true);

        $("#ckcontent").show();
      
        setTimeout(function(){
           $('#textTitle').prop('disabled', false);
       },4000);
      
     });
});
</script>
</head>
<body>

<div id="btnregister" name="registerbtn">
<p>jQuery disable button — Disabling and enabling buttons with jQuery</p>
    <input type="submit" value="Click me!" id="textTitle" name="textTitle"/>
</div>
  
<div style="display:none;" id="ckcontent">
  The above Clcik button disables for 4 seconds, on clicking.                
</div>

</body>
</html>

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about jQuery Enable Disable Submit Button Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Disable submit button until Ajax Completes Example 0

Disable submit button until Ajax Completes Example

Disable submit button until Ajax Completes Example

Welcome to the In Pakainfo.com website! You will Step By Step learn web programming, easy and very fun. This website allmost provides you with a complete web programming tutorial presented in an easy-to-follow manner. Each web programming tutorial has all the practical examples with web programming script and screenshots available.For

index.html

This is a short Post on how to my submit button disable a button until an call the Ajax request has been completed or done.

<!DOCTYPE html>
<html>
    <head>
        <title>jquery disable button after click submit form example</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    </head>
    <body>
        <p>Click the submit button below to this disable it!</p>
        <button id="mybutton_submit">Submite</button>
        
        <script>
            
            //Add a  button click event handler to each our button.
            $('#mybutton_submit').on('click', function(){
                
                //here Disable each  button set attribues
                $('#mybutton_submit').attr("disabled", true);
                
                var seturl = window.location.href;
                
                $.ajax({
                    url: seturl,
                    success: function(data){
                        //The Ajax request was a success.
                        //Do here code enable or disable something in here.
                    },
                    complete: function(){
                        //Ajax  call request is finished or done, so we can enable my submit button
                        //the button again call.
                        $('#mybutton_submit').attr("disabled", false);
                    }
                });
            });

        </script>
    </body>
</html>

how to disable or enable button using jquery Ajax Call

$("input[name=groups-name]").blur(function () {
		$('#loading-div').show();
		$('#findgroups').hide();
		var pclass=$(this).attr('class').split(' ')[1];
	   $.ajax({
			type: 'POST',
			url: 'php/getid.php',
			dataType: 'json',
			data: { 'name' : $(this).val() },
			success : function(result){
					$('#loading-div').hide();
					$('#findgroups').show();
					if(pclass=='groups')
					{
						var result=result+"/"+pclass+"/";
					}
					
					$('input[name=groups-name]').attr('format',result);
				
			},error: function (jqXHR, exception) {
				$('#findgroups').show();
				$('#loading-div').html("<b style='color:red'>Please Enter Valid keywords</b>");
			}
		});
	});
});

jquery disable button after click for 5 seconds Example

jquery call the ajax after the setTimeout function call to the simple 5 seconds button automatically enable.

var fewSeconds = 5;
$('#btnadd').click(function(){
    // simple Ajax request
    var btnadd = $(this);
    btnadd.prop('disabled', true);
    setTimeout(function(){
        btnadd.prop('disabled', false);
    }, fewSeconds*1000);
});

Example 1

Example 2

jquery disable button after click submit form | how to disable a button in jquery | jquery disable button after click for 5 seconds | jquery ajax get example