hello all, am in need of a onsubmit or onclick form disable for xamount of minute.
i don’t want to disable the button just the form, d user can keep clicking the button but once d form is disable, it wont submit values, this is possible right.
You only need to prevent the default submit action for the time duration. Although I would disable the submit button since that is the primary cue for the user that the form will not submit.
Na d primary cue is d form it self reason is that i want d user to click d button to download a file once after which d form disasble for some time so wen d user click d button aagain only d file is downloaded but value isnt sent to database thats what am trying to accomplish
He wants a debounce function, so that it doesn’t submit again until a period of time has elapsed.
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};