Button value to be changed back to original value on timeout (form double submit) Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience Should we burninate the [wrap] tag? The Ask Question Wizard is Live!Prevent double submission of forms in jQueryJavaScript post request like a form submitChange the selected value of a drop-down list with jQueryTwo submit buttons in one formPrevent users from submitting a form by hitting EnterHow to prevent buttons from submitting formsjQuery disable/enable submit buttonjQuery AJAX submit formHTML button to NOT submit formCan I make a <button> not submit a form?Cannot display HTML string

Why is "Consequences inflicted." not a sentence?

What exactly is a "Meth" in Altered Carbon?

What does an IRS interview request entail when called in to verify expenses for a sole proprietor small business?

How to Merge Multiple Columns in to Two Columns based on Column 1 Value?

Why are there no cargo aircraft with "flying wing" design?

Sci-Fi book where patients in a coma ward all live in a subconscious world linked together

Should I use a zero-interest credit card for a large one-time purchase?

How do I keep my slimes from escaping their pens?

Short Story with Cinderella as a Voo-doo Witch

When a candle burns, why does the top of wick glow if bottom of flame is hottest?

Resolving to minmaj7

Error "illegal generic type for instanceof" when using local classes

Why light coming from distant stars is not discreet?

Is the Standard Deduction better than Itemized when both are the same amount?

What causes the vertical darker bands in my photo?

How do I stop a creek from eroding my steep embankment?

How to run gsettings for another user Ubuntu 18.04.2 LTS

Why am I getting the error "non-boolean type specified in a context where a condition is expected" for this request?

Is it true that "carbohydrates are of no use for the basal metabolic need"?

In predicate logic, does existential quantification (∃) include universal quantification (∀), i.e. can 'some' imply 'all'?

What is a non-alternating simple group with big order, but relatively few conjugacy classes?

At the end of Thor: Ragnarok why don't the Asgardians turn and head for the Bifrost as per their original plan?

Why do we bend a book to keep it straight?

What to do with chalk when deepwater soloing?



Button value to be changed back to original value on timeout (form double submit)



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
Should we burninate the [wrap] tag?
The Ask Question Wizard is Live!Prevent double submission of forms in jQueryJavaScript post request like a form submitChange the selected value of a drop-down list with jQueryTwo submit buttons in one formPrevent users from submitting a form by hitting EnterHow to prevent buttons from submitting formsjQuery disable/enable submit buttonjQuery AJAX submit formHTML button to NOT submit formCan I make a <button> not submit a form?Cannot display HTML string



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








8















I am trying to fix a form double submit by disabling the submit button temporarily and changing the submit button value to "processing..." so the user knows what is going on.



The disable works onClick and the "Submit" value changes to "processing...", however I am unable to change the value back to "Submit" after the setTimeout function has ended.



Does anyone know how I could go about doing this?






$(function() 
$("#submit_btn").click(function()
$("#submit_btn").attr("disabled", "disabled");
this.value = "Processing...";
setTimeout(function()
this.value = "Submit"; //<- this line doesn't work
$("#submit_btn").removeAttr("disabled");
, 5000);
);
);

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="submit_btn" type="submit" value="Submit" />












share|improve this question






























    8















    I am trying to fix a form double submit by disabling the submit button temporarily and changing the submit button value to "processing..." so the user knows what is going on.



    The disable works onClick and the "Submit" value changes to "processing...", however I am unable to change the value back to "Submit" after the setTimeout function has ended.



    Does anyone know how I could go about doing this?






    $(function() 
    $("#submit_btn").click(function()
    $("#submit_btn").attr("disabled", "disabled");
    this.value = "Processing...";
    setTimeout(function()
    this.value = "Submit"; //<- this line doesn't work
    $("#submit_btn").removeAttr("disabled");
    , 5000);
    );
    );

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <input id="submit_btn" type="submit" value="Submit" />












    share|improve this question


























      8












      8








      8


      2






      I am trying to fix a form double submit by disabling the submit button temporarily and changing the submit button value to "processing..." so the user knows what is going on.



      The disable works onClick and the "Submit" value changes to "processing...", however I am unable to change the value back to "Submit" after the setTimeout function has ended.



      Does anyone know how I could go about doing this?






      $(function() 
      $("#submit_btn").click(function()
      $("#submit_btn").attr("disabled", "disabled");
      this.value = "Processing...";
      setTimeout(function()
      this.value = "Submit"; //<- this line doesn't work
      $("#submit_btn").removeAttr("disabled");
      , 5000);
      );
      );

      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <input id="submit_btn" type="submit" value="Submit" />












      share|improve this question
















      I am trying to fix a form double submit by disabling the submit button temporarily and changing the submit button value to "processing..." so the user knows what is going on.



      The disable works onClick and the "Submit" value changes to "processing...", however I am unable to change the value back to "Submit" after the setTimeout function has ended.



      Does anyone know how I could go about doing this?






      $(function() 
      $("#submit_btn").click(function()
      $("#submit_btn").attr("disabled", "disabled");
      this.value = "Processing...";
      setTimeout(function()
      this.value = "Submit"; //<- this line doesn't work
      $("#submit_btn").removeAttr("disabled");
      , 5000);
      );
      );

      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <input id="submit_btn" type="submit" value="Submit" />








      $(function() 
      $("#submit_btn").click(function()
      $("#submit_btn").attr("disabled", "disabled");
      this.value = "Processing...";
      setTimeout(function()
      this.value = "Submit"; //<- this line doesn't work
      $("#submit_btn").removeAttr("disabled");
      , 5000);
      );
      );

      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <input id="submit_btn" type="submit" value="Submit" />





      $(function() 
      $("#submit_btn").click(function()
      $("#submit_btn").attr("disabled", "disabled");
      this.value = "Processing...";
      setTimeout(function()
      this.value = "Submit"; //<- this line doesn't work
      $("#submit_btn").removeAttr("disabled");
      , 5000);
      );
      );

      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <input id="submit_btn" type="submit" value="Submit" />






      javascript jquery html






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 1 at 6:49









      Arend

      3,53012137




      3,53012137










      asked Apr 1 at 5:50









      RobertRobert

      616




      616






















          5 Answers
          5






          active

          oldest

          votes


















          6














          Just change this to $("#submit_btn") and it works:






          $(function() 
          $("#submit_btn").click(function()
          $("#submit_btn").attr("disabled", "disabled");
          $("#submit_btn").val("Processing...");
          setTimeout(function()
          $("#submit_btn").val("Submit");
          $("#submit_btn").removeAttr("disabled");
          , 5000);
          );
          );

          <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
          <input id="submit_btn" type="submit" value="Submit" />





          The issue was that your functions were interfering with this. You could have done self = this which would have had the same effect:






          $(function() 
          $("#submit_btn").click(function()
          var self = this;
          $(self).attr("disabled", "disabled");
          $(self).val("Processing...");
          setTimeout(function()
          $(self).val("Submit");
          $(self).removeAttr("disabled");
          , 5000);
          );
          );

          <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
          <input id="submit_btn" type="submit" value="Submit" />





          Or you could have used event.target:






          $(function() 
          $("#submit_btn").click(function(event)
          $(event.target).attr("disabled", "disabled");
          $(event.target).val("Processing...");
          setTimeout(function()
          $(event.target).val("Submit");
          $(event.target).removeAttr("disabled");
          , 5000);
          );
          );

          <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
          <input id="submit_btn" type="submit" value="Submit" />








          share|improve this answer




















          • 1





            Explanation is needed to understand why you did what you did (and I didn't downvote).

            – LGSon
            Apr 1 at 6:03







          • 1





            Oh yes @LGSon - I'll add that.

            – Jack Bashford
            Apr 1 at 6:03






          • 1





            Awesome thanks man. I swear I tried that approach before I posted this question... must have forgotten a semi colon or something lol, rookie mistake. I'll accept your answer in 3 minutes when stackoverflow allows me. Cheers!

            – Robert
            Apr 1 at 6:04


















          2














          you just need to replace that line with the following code:
          $("#submit_btn").val("Submit");



          you should use val function to change the text of the button.






          share|improve this answer






























            2














             $(function() 
            $("#submit_btn").click(function(event)
            $('button').button( loadingText: 'Processing..' );
            $('#submit_btn').button('loading');
            //after submit stuff put below line to reset;
            $('#submit_btn').button('reset');
            );
            );


            above code work best when you used
            html button in place of input type button
            Note-- To Show Spin Icon inside Button put
            font-awesome or any other icon in place of Processing.. or both in loadingText object






            share|improve this answer

























            • it prevent multiple click (submit) until first click event completed by... disabling button by default ,,

              – Haider Ali
              Apr 1 at 7:09


















            1














            $(document).ready(function() 
            $(function()
            $("#submit_btn").click(function()
            $("#submit_btn").attr("disabled", "disabled");
            this.value = "Processing...";
            outerthis = this;
            setTimeout(function()
            outerthis.value = "Submit";
            $("#submit_btn").removeAttr("disabled");
            , 5000);
            );
            );
            );





            share|improve this answer
































              0














              Problem about the wrong usage of this keyword inside setTimeout() has already been explained. However, if you are able to use arrow function expressions (ES6 feature), that won't be a problem:




              An arrow function expression is a syntactically compact alternative to a regular function expression, although without its own bindings to the this, arguments, super, or new.target keywords.




              Using this feature, your code can be simplified a little as shown on next example:






              $("#submit_btn").click(function()

              $(this).attr("disabled", "disabled").val("Processing...");

              setTimeout(
              () => $(this).val("Submit").removeAttr("disabled"),
              5000
              );
              );

              <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
              <input id="submit_btn" type="submit" value="Submit" />








              share|improve this answer

























                Your Answer






                StackExchange.ifUsing("editor", function ()
                StackExchange.using("externalEditor", function ()
                StackExchange.using("snippets", function ()
                StackExchange.snippets.init();
                );
                );
                , "code-snippets");

                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "1"
                ;
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function()
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled)
                StackExchange.using("snippets", function()
                createEditor();
                );

                else
                createEditor();

                );

                function createEditor()
                StackExchange.prepareEditor(
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader:
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                ,
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                );



                );













                draft saved

                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55448780%2fbutton-value-to-be-changed-back-to-original-value-on-timeout-form-double-submit%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                5 Answers
                5






                active

                oldest

                votes








                5 Answers
                5






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                6














                Just change this to $("#submit_btn") and it works:






                $(function() 
                $("#submit_btn").click(function()
                $("#submit_btn").attr("disabled", "disabled");
                $("#submit_btn").val("Processing...");
                setTimeout(function()
                $("#submit_btn").val("Submit");
                $("#submit_btn").removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />





                The issue was that your functions were interfering with this. You could have done self = this which would have had the same effect:






                $(function() 
                $("#submit_btn").click(function()
                var self = this;
                $(self).attr("disabled", "disabled");
                $(self).val("Processing...");
                setTimeout(function()
                $(self).val("Submit");
                $(self).removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />





                Or you could have used event.target:






                $(function() 
                $("#submit_btn").click(function(event)
                $(event.target).attr("disabled", "disabled");
                $(event.target).val("Processing...");
                setTimeout(function()
                $(event.target).val("Submit");
                $(event.target).removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />








                share|improve this answer




















                • 1





                  Explanation is needed to understand why you did what you did (and I didn't downvote).

                  – LGSon
                  Apr 1 at 6:03







                • 1





                  Oh yes @LGSon - I'll add that.

                  – Jack Bashford
                  Apr 1 at 6:03






                • 1





                  Awesome thanks man. I swear I tried that approach before I posted this question... must have forgotten a semi colon or something lol, rookie mistake. I'll accept your answer in 3 minutes when stackoverflow allows me. Cheers!

                  – Robert
                  Apr 1 at 6:04















                6














                Just change this to $("#submit_btn") and it works:






                $(function() 
                $("#submit_btn").click(function()
                $("#submit_btn").attr("disabled", "disabled");
                $("#submit_btn").val("Processing...");
                setTimeout(function()
                $("#submit_btn").val("Submit");
                $("#submit_btn").removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />





                The issue was that your functions were interfering with this. You could have done self = this which would have had the same effect:






                $(function() 
                $("#submit_btn").click(function()
                var self = this;
                $(self).attr("disabled", "disabled");
                $(self).val("Processing...");
                setTimeout(function()
                $(self).val("Submit");
                $(self).removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />





                Or you could have used event.target:






                $(function() 
                $("#submit_btn").click(function(event)
                $(event.target).attr("disabled", "disabled");
                $(event.target).val("Processing...");
                setTimeout(function()
                $(event.target).val("Submit");
                $(event.target).removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />








                share|improve this answer




















                • 1





                  Explanation is needed to understand why you did what you did (and I didn't downvote).

                  – LGSon
                  Apr 1 at 6:03







                • 1





                  Oh yes @LGSon - I'll add that.

                  – Jack Bashford
                  Apr 1 at 6:03






                • 1





                  Awesome thanks man. I swear I tried that approach before I posted this question... must have forgotten a semi colon or something lol, rookie mistake. I'll accept your answer in 3 minutes when stackoverflow allows me. Cheers!

                  – Robert
                  Apr 1 at 6:04













                6












                6








                6







                Just change this to $("#submit_btn") and it works:






                $(function() 
                $("#submit_btn").click(function()
                $("#submit_btn").attr("disabled", "disabled");
                $("#submit_btn").val("Processing...");
                setTimeout(function()
                $("#submit_btn").val("Submit");
                $("#submit_btn").removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />





                The issue was that your functions were interfering with this. You could have done self = this which would have had the same effect:






                $(function() 
                $("#submit_btn").click(function()
                var self = this;
                $(self).attr("disabled", "disabled");
                $(self).val("Processing...");
                setTimeout(function()
                $(self).val("Submit");
                $(self).removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />





                Or you could have used event.target:






                $(function() 
                $("#submit_btn").click(function(event)
                $(event.target).attr("disabled", "disabled");
                $(event.target).val("Processing...");
                setTimeout(function()
                $(event.target).val("Submit");
                $(event.target).removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />








                share|improve this answer















                Just change this to $("#submit_btn") and it works:






                $(function() 
                $("#submit_btn").click(function()
                $("#submit_btn").attr("disabled", "disabled");
                $("#submit_btn").val("Processing...");
                setTimeout(function()
                $("#submit_btn").val("Submit");
                $("#submit_btn").removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />





                The issue was that your functions were interfering with this. You could have done self = this which would have had the same effect:






                $(function() 
                $("#submit_btn").click(function()
                var self = this;
                $(self).attr("disabled", "disabled");
                $(self).val("Processing...");
                setTimeout(function()
                $(self).val("Submit");
                $(self).removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />





                Or you could have used event.target:






                $(function() 
                $("#submit_btn").click(function(event)
                $(event.target).attr("disabled", "disabled");
                $(event.target).val("Processing...");
                setTimeout(function()
                $(event.target).val("Submit");
                $(event.target).removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />








                $(function() 
                $("#submit_btn").click(function()
                $("#submit_btn").attr("disabled", "disabled");
                $("#submit_btn").val("Processing...");
                setTimeout(function()
                $("#submit_btn").val("Submit");
                $("#submit_btn").removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />





                $(function() 
                $("#submit_btn").click(function()
                $("#submit_btn").attr("disabled", "disabled");
                $("#submit_btn").val("Processing...");
                setTimeout(function()
                $("#submit_btn").val("Submit");
                $("#submit_btn").removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />





                $(function() 
                $("#submit_btn").click(function()
                var self = this;
                $(self).attr("disabled", "disabled");
                $(self).val("Processing...");
                setTimeout(function()
                $(self).val("Submit");
                $(self).removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />





                $(function() 
                $("#submit_btn").click(function()
                var self = this;
                $(self).attr("disabled", "disabled");
                $(self).val("Processing...");
                setTimeout(function()
                $(self).val("Submit");
                $(self).removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />





                $(function() 
                $("#submit_btn").click(function(event)
                $(event.target).attr("disabled", "disabled");
                $(event.target).val("Processing...");
                setTimeout(function()
                $(event.target).val("Submit");
                $(event.target).removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />





                $(function() 
                $("#submit_btn").click(function(event)
                $(event.target).attr("disabled", "disabled");
                $(event.target).val("Processing...");
                setTimeout(function()
                $(event.target).val("Submit");
                $(event.target).removeAttr("disabled");
                , 5000);
                );
                );

                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                <input id="submit_btn" type="submit" value="Submit" />






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 1 at 6:06

























                answered Apr 1 at 6:01









                Jack BashfordJack Bashford

                17.1k51849




                17.1k51849







                • 1





                  Explanation is needed to understand why you did what you did (and I didn't downvote).

                  – LGSon
                  Apr 1 at 6:03







                • 1





                  Oh yes @LGSon - I'll add that.

                  – Jack Bashford
                  Apr 1 at 6:03






                • 1





                  Awesome thanks man. I swear I tried that approach before I posted this question... must have forgotten a semi colon or something lol, rookie mistake. I'll accept your answer in 3 minutes when stackoverflow allows me. Cheers!

                  – Robert
                  Apr 1 at 6:04












                • 1





                  Explanation is needed to understand why you did what you did (and I didn't downvote).

                  – LGSon
                  Apr 1 at 6:03







                • 1





                  Oh yes @LGSon - I'll add that.

                  – Jack Bashford
                  Apr 1 at 6:03






                • 1





                  Awesome thanks man. I swear I tried that approach before I posted this question... must have forgotten a semi colon or something lol, rookie mistake. I'll accept your answer in 3 minutes when stackoverflow allows me. Cheers!

                  – Robert
                  Apr 1 at 6:04







                1




                1





                Explanation is needed to understand why you did what you did (and I didn't downvote).

                – LGSon
                Apr 1 at 6:03






                Explanation is needed to understand why you did what you did (and I didn't downvote).

                – LGSon
                Apr 1 at 6:03





                1




                1





                Oh yes @LGSon - I'll add that.

                – Jack Bashford
                Apr 1 at 6:03





                Oh yes @LGSon - I'll add that.

                – Jack Bashford
                Apr 1 at 6:03




                1




                1





                Awesome thanks man. I swear I tried that approach before I posted this question... must have forgotten a semi colon or something lol, rookie mistake. I'll accept your answer in 3 minutes when stackoverflow allows me. Cheers!

                – Robert
                Apr 1 at 6:04





                Awesome thanks man. I swear I tried that approach before I posted this question... must have forgotten a semi colon or something lol, rookie mistake. I'll accept your answer in 3 minutes when stackoverflow allows me. Cheers!

                – Robert
                Apr 1 at 6:04













                2














                you just need to replace that line with the following code:
                $("#submit_btn").val("Submit");



                you should use val function to change the text of the button.






                share|improve this answer



























                  2














                  you just need to replace that line with the following code:
                  $("#submit_btn").val("Submit");



                  you should use val function to change the text of the button.






                  share|improve this answer

























                    2












                    2








                    2







                    you just need to replace that line with the following code:
                    $("#submit_btn").val("Submit");



                    you should use val function to change the text of the button.






                    share|improve this answer













                    you just need to replace that line with the following code:
                    $("#submit_btn").val("Submit");



                    you should use val function to change the text of the button.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Apr 1 at 7:02









                    AnaghaAnagha

                    673




                    673





















                        2














                         $(function() 
                        $("#submit_btn").click(function(event)
                        $('button').button( loadingText: 'Processing..' );
                        $('#submit_btn').button('loading');
                        //after submit stuff put below line to reset;
                        $('#submit_btn').button('reset');
                        );
                        );


                        above code work best when you used
                        html button in place of input type button
                        Note-- To Show Spin Icon inside Button put
                        font-awesome or any other icon in place of Processing.. or both in loadingText object






                        share|improve this answer

























                        • it prevent multiple click (submit) until first click event completed by... disabling button by default ,,

                          – Haider Ali
                          Apr 1 at 7:09















                        2














                         $(function() 
                        $("#submit_btn").click(function(event)
                        $('button').button( loadingText: 'Processing..' );
                        $('#submit_btn').button('loading');
                        //after submit stuff put below line to reset;
                        $('#submit_btn').button('reset');
                        );
                        );


                        above code work best when you used
                        html button in place of input type button
                        Note-- To Show Spin Icon inside Button put
                        font-awesome or any other icon in place of Processing.. or both in loadingText object






                        share|improve this answer

























                        • it prevent multiple click (submit) until first click event completed by... disabling button by default ,,

                          – Haider Ali
                          Apr 1 at 7:09













                        2












                        2








                        2







                         $(function() 
                        $("#submit_btn").click(function(event)
                        $('button').button( loadingText: 'Processing..' );
                        $('#submit_btn').button('loading');
                        //after submit stuff put below line to reset;
                        $('#submit_btn').button('reset');
                        );
                        );


                        above code work best when you used
                        html button in place of input type button
                        Note-- To Show Spin Icon inside Button put
                        font-awesome or any other icon in place of Processing.. or both in loadingText object






                        share|improve this answer















                         $(function() 
                        $("#submit_btn").click(function(event)
                        $('button').button( loadingText: 'Processing..' );
                        $('#submit_btn').button('loading');
                        //after submit stuff put below line to reset;
                        $('#submit_btn').button('reset');
                        );
                        );


                        above code work best when you used
                        html button in place of input type button
                        Note-- To Show Spin Icon inside Button put
                        font-awesome or any other icon in place of Processing.. or both in loadingText object







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Apr 1 at 7:11

























                        answered Apr 1 at 6:56









                        Haider AliHaider Ali

                        213




                        213












                        • it prevent multiple click (submit) until first click event completed by... disabling button by default ,,

                          – Haider Ali
                          Apr 1 at 7:09

















                        • it prevent multiple click (submit) until first click event completed by... disabling button by default ,,

                          – Haider Ali
                          Apr 1 at 7:09
















                        it prevent multiple click (submit) until first click event completed by... disabling button by default ,,

                        – Haider Ali
                        Apr 1 at 7:09





                        it prevent multiple click (submit) until first click event completed by... disabling button by default ,,

                        – Haider Ali
                        Apr 1 at 7:09











                        1














                        $(document).ready(function() 
                        $(function()
                        $("#submit_btn").click(function()
                        $("#submit_btn").attr("disabled", "disabled");
                        this.value = "Processing...";
                        outerthis = this;
                        setTimeout(function()
                        outerthis.value = "Submit";
                        $("#submit_btn").removeAttr("disabled");
                        , 5000);
                        );
                        );
                        );





                        share|improve this answer





























                          1














                          $(document).ready(function() 
                          $(function()
                          $("#submit_btn").click(function()
                          $("#submit_btn").attr("disabled", "disabled");
                          this.value = "Processing...";
                          outerthis = this;
                          setTimeout(function()
                          outerthis.value = "Submit";
                          $("#submit_btn").removeAttr("disabled");
                          , 5000);
                          );
                          );
                          );





                          share|improve this answer



























                            1












                            1








                            1







                            $(document).ready(function() 
                            $(function()
                            $("#submit_btn").click(function()
                            $("#submit_btn").attr("disabled", "disabled");
                            this.value = "Processing...";
                            outerthis = this;
                            setTimeout(function()
                            outerthis.value = "Submit";
                            $("#submit_btn").removeAttr("disabled");
                            , 5000);
                            );
                            );
                            );





                            share|improve this answer















                            $(document).ready(function() 
                            $(function()
                            $("#submit_btn").click(function()
                            $("#submit_btn").attr("disabled", "disabled");
                            this.value = "Processing...";
                            outerthis = this;
                            setTimeout(function()
                            outerthis.value = "Submit";
                            $("#submit_btn").removeAttr("disabled");
                            , 5000);
                            );
                            );
                            );






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Apr 1 at 8:10









                            Arend

                            3,53012137




                            3,53012137










                            answered Apr 1 at 6:28









                            SINGH AAKASHSINGH AAKASH

                            192




                            192





















                                0














                                Problem about the wrong usage of this keyword inside setTimeout() has already been explained. However, if you are able to use arrow function expressions (ES6 feature), that won't be a problem:




                                An arrow function expression is a syntactically compact alternative to a regular function expression, although without its own bindings to the this, arguments, super, or new.target keywords.




                                Using this feature, your code can be simplified a little as shown on next example:






                                $("#submit_btn").click(function()

                                $(this).attr("disabled", "disabled").val("Processing...");

                                setTimeout(
                                () => $(this).val("Submit").removeAttr("disabled"),
                                5000
                                );
                                );

                                <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                                <input id="submit_btn" type="submit" value="Submit" />








                                share|improve this answer





























                                  0














                                  Problem about the wrong usage of this keyword inside setTimeout() has already been explained. However, if you are able to use arrow function expressions (ES6 feature), that won't be a problem:




                                  An arrow function expression is a syntactically compact alternative to a regular function expression, although without its own bindings to the this, arguments, super, or new.target keywords.




                                  Using this feature, your code can be simplified a little as shown on next example:






                                  $("#submit_btn").click(function()

                                  $(this).attr("disabled", "disabled").val("Processing...");

                                  setTimeout(
                                  () => $(this).val("Submit").removeAttr("disabled"),
                                  5000
                                  );
                                  );

                                  <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                                  <input id="submit_btn" type="submit" value="Submit" />








                                  share|improve this answer



























                                    0












                                    0








                                    0







                                    Problem about the wrong usage of this keyword inside setTimeout() has already been explained. However, if you are able to use arrow function expressions (ES6 feature), that won't be a problem:




                                    An arrow function expression is a syntactically compact alternative to a regular function expression, although without its own bindings to the this, arguments, super, or new.target keywords.




                                    Using this feature, your code can be simplified a little as shown on next example:






                                    $("#submit_btn").click(function()

                                    $(this).attr("disabled", "disabled").val("Processing...");

                                    setTimeout(
                                    () => $(this).val("Submit").removeAttr("disabled"),
                                    5000
                                    );
                                    );

                                    <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                                    <input id="submit_btn" type="submit" value="Submit" />








                                    share|improve this answer















                                    Problem about the wrong usage of this keyword inside setTimeout() has already been explained. However, if you are able to use arrow function expressions (ES6 feature), that won't be a problem:




                                    An arrow function expression is a syntactically compact alternative to a regular function expression, although without its own bindings to the this, arguments, super, or new.target keywords.




                                    Using this feature, your code can be simplified a little as shown on next example:






                                    $("#submit_btn").click(function()

                                    $(this).attr("disabled", "disabled").val("Processing...");

                                    setTimeout(
                                    () => $(this).val("Submit").removeAttr("disabled"),
                                    5000
                                    );
                                    );

                                    <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                                    <input id="submit_btn" type="submit" value="Submit" />








                                    $("#submit_btn").click(function()

                                    $(this).attr("disabled", "disabled").val("Processing...");

                                    setTimeout(
                                    () => $(this).val("Submit").removeAttr("disabled"),
                                    5000
                                    );
                                    );

                                    <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                                    <input id="submit_btn" type="submit" value="Submit" />





                                    $("#submit_btn").click(function()

                                    $(this).attr("disabled", "disabled").val("Processing...");

                                    setTimeout(
                                    () => $(this).val("Submit").removeAttr("disabled"),
                                    5000
                                    );
                                    );

                                    <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
                                    <input id="submit_btn" type="submit" value="Submit" />






                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Apr 1 at 18:50

























                                    answered Apr 1 at 18:28









                                    ShiderszShidersz

                                    10.4k2933




                                    10.4k2933



























                                        draft saved

                                        draft discarded
















































                                        Thanks for contributing an answer to Stack Overflow!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid


                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.

                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55448780%2fbutton-value-to-be-changed-back-to-original-value-on-timeout-form-double-submit%23new-answer', 'question_page');

                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Triangular numbers and gcdProving sum of a set is $0 pmod n$ if $n$ is odd, or $fracn2 pmod n$ if $n$ is even?Is greatest common divisor of two numbers really their smallest linear combination?GCD, LCM RelationshipProve a set of nonnegative integers with greatest common divisor 1 and closed under addition has all but finite many nonnegative integers.all pairs of a and b in an equation containing gcdTriangular Numbers Modulo $k$ - Hit All Values?Understanding the Existence and Uniqueness of the GCDGCD and LCM with logical symbolsThe greatest common divisor of two positive integers less than 100 is equal to 3. Their least common multiple is twelve times one of the integers.Suppose that for all integers $x$, $x|a$ and $x|b$ if and only if $x|c$. Then $c = gcd(a,b)$Which is the gcd of 2 numbers which are multiplied and the result is 600000?

                                        Ingelân Ynhâld Etymology | Geografy | Skiednis | Polityk en bestjoer | Ekonomy | Demografy | Kultuer | Klimaat | Sjoch ek | Keppelings om utens | Boarnen, noaten en referinsjes Navigaasjemenuwww.gov.ukOffisjele webside fan it regear fan it Feriene KeninkrykOffisjele webside fan it Britske FerkearsburoNederlânsktalige ynformaasje fan it Britske FerkearsburoOffisjele webside fan English Heritage, de organisaasje dy't him ynset foar it behâld fan it Ingelske kultuergoedYnwennertallen fan alle Britske stêden út 'e folkstelling fan 2011Notes en References, op dizze sideEngland

                                        Հադիս Բովանդակություն Անվանում և նշանակություն | Դասակարգում | Աղբյուրներ | Նավարկման ցանկ