Button value to be changed back to original value on timeout (form double submit) The Next CEO of Stack OverflowPrevent 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 can't we say "I have been having a dog"?
That's an odd coin - I wonder why
Why doesn't Shulchan Aruch include the laws of destroying fruit trees?
Direct Implications Between USA and UK in Event of No-Deal Brexit
Is this a new Fibonacci Identity?
Can Sri Krishna be called 'a person'?
Is it correct to say moon starry nights?
How badly should I try to prevent a user from XSSing themselves?
Prodigo = pro + ago?
How to implement Comparable so it is consistent with identity-equality
Car headlights in a world without electricity
Is a distribution that is normal, but highly skewed, considered Gaussian?
Can a PhD from a non-TU9 German university become a professor in a TU9 university?
Is it okay to majorly distort historical facts while writing a fiction story?
How can a day be of 24 hours?
Creating a script with console commands
logical reads on global temp table, but not on session-level temp table
Can this transistor (2n2222) take 6V on emitter-base? Am I reading datasheet incorrectly?
Find the majority element, which appears more than half the time
How can the PCs determine if an item is a phylactery?
How can I separate the number from the unit in argument?
How to pronounce fünf in 45
Compensation for working overtime on Saturdays
Could a dragon use its wings to swim?
Button value to be changed back to original value on timeout (form double submit)
The Next CEO of Stack OverflowPrevent 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
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" />javascript jquery html
add a comment |
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" />javascript jquery html
add a comment |
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" />javascript jquery html
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
javascript jquery html
edited 18 hours ago
Arend
3,53012137
3,53012137
asked 19 hours ago
RobertRobert
596
596
add a comment |
add a comment |
5 Answers
5
active
oldest
votes
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" />
1
Explanation is needed to understand why you did what you did (and I didn't downvote).
– LGSon
19 hours ago
1
Oh yes @LGSon - I'll add that.
– Jack Bashford
19 hours ago
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
19 hours ago
add a comment |
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.
New contributor
Anagha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
$(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
New contributor
Haider Ali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
it prevent multiple click (submit) until first click event completed by... disabling button by default ,,
– Haider Ali
18 hours ago
add a comment |
$(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);
);
);
);
New contributor
SINGH AAKASH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
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" />add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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" />
1
Explanation is needed to understand why you did what you did (and I didn't downvote).
– LGSon
19 hours ago
1
Oh yes @LGSon - I'll add that.
– Jack Bashford
19 hours ago
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
19 hours ago
add a comment |
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" />
1
Explanation is needed to understand why you did what you did (and I didn't downvote).
– LGSon
19 hours ago
1
Oh yes @LGSon - I'll add that.
– Jack Bashford
19 hours ago
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
19 hours ago
add a comment |
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" />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" />edited 19 hours ago
answered 19 hours ago
Jack BashfordJack Bashford
14.4k31848
14.4k31848
1
Explanation is needed to understand why you did what you did (and I didn't downvote).
– LGSon
19 hours ago
1
Oh yes @LGSon - I'll add that.
– Jack Bashford
19 hours ago
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
19 hours ago
add a comment |
1
Explanation is needed to understand why you did what you did (and I didn't downvote).
– LGSon
19 hours ago
1
Oh yes @LGSon - I'll add that.
– Jack Bashford
19 hours ago
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
19 hours ago
1
1
Explanation is needed to understand why you did what you did (and I didn't downvote).
– LGSon
19 hours ago
Explanation is needed to understand why you did what you did (and I didn't downvote).
– LGSon
19 hours ago
1
1
Oh yes @LGSon - I'll add that.
– Jack Bashford
19 hours ago
Oh yes @LGSon - I'll add that.
– Jack Bashford
19 hours ago
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
19 hours ago
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
19 hours ago
add a comment |
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.
New contributor
Anagha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
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.
New contributor
Anagha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
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.
New contributor
Anagha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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.
New contributor
Anagha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Anagha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 18 hours ago
AnaghaAnagha
462
462
New contributor
Anagha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Anagha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Anagha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
$(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
New contributor
Haider Ali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
it prevent multiple click (submit) until first click event completed by... disabling button by default ,,
– Haider Ali
18 hours ago
add a comment |
$(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
New contributor
Haider Ali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
it prevent multiple click (submit) until first click event completed by... disabling button by default ,,
– Haider Ali
18 hours ago
add a comment |
$(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
New contributor
Haider Ali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$(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
New contributor
Haider Ali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 18 hours ago
New contributor
Haider Ali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 18 hours ago
Haider AliHaider Ali
213
213
New contributor
Haider Ali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Haider Ali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Haider Ali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
it prevent multiple click (submit) until first click event completed by... disabling button by default ,,
– Haider Ali
18 hours ago
add a comment |
it prevent multiple click (submit) until first click event completed by... disabling button by default ,,
– Haider Ali
18 hours ago
it prevent multiple click (submit) until first click event completed by... disabling button by default ,,
– Haider Ali
18 hours ago
it prevent multiple click (submit) until first click event completed by... disabling button by default ,,
– Haider Ali
18 hours ago
add a comment |
$(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);
);
);
);
New contributor
SINGH AAKASH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
$(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);
);
);
);
New contributor
SINGH AAKASH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
$(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);
);
);
);
New contributor
SINGH AAKASH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$(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);
);
);
);
New contributor
SINGH AAKASH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 17 hours ago
Arend
3,53012137
3,53012137
New contributor
SINGH AAKASH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 18 hours ago
SINGH AAKASHSINGH AAKASH
192
192
New contributor
SINGH AAKASH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
SINGH AAKASH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
SINGH AAKASH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
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" />add a comment |
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" />add a comment |
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" />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" />edited 6 hours ago
answered 6 hours ago
ShiderszShidersz
9,4382933
9,4382933
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
