Onclick or onsubmit

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.

thank you.

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.

Wouldn’t a debounce technique be successful here?

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

Could you repeat that sentence in a readable language, please?

1 Like

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);
	};
};

source: https://davidwalsh.name/javascript-debounce-function

Yh something like that can i plz get that in an html form thanks.
Never heard bout debounce b4 thou

That’s only a part of it, you need to have an event listener for the form submit, and a handler to help join things together.

I’m not keen on doing a cooking show and whipping out a meal that was prepared earlier, for not much is learned there.

Instead, I’ll as you to set up a form and then add an event listener for that form.

Am not saying it won’t just saying never heard of it thats all

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.