[Fix] Prevent clicking of signup button repeatedly

This commit is contained in:
James Musselman 2023-11-29 17:41:04 -06:00
parent 8020e8dcd0
commit d2ed1a6007

View file

@ -60,6 +60,21 @@ function checkUsernameAvailability() {
} }
}; };
xhr.send(); xhr.send();
// Disable the button to prevent multiple clicks
submitBtn.disabled = true;
// Show the spinner
const spinner = document.createElement('i');
spinner.classList.add('fas', 'fa-spinner', 'fa-spin');
submitBtn.innerHTML = '';
submitBtn.appendChild(spinner);
// Enable the button and remove the spinner after 5 seconds
setTimeout(function () {
submitBtn.disabled = false;
submitBtn.innerHTML = 'Sign Up';
}, 5000);
sleep(5000).then(() => { submitBtn.disabled = false; });
} }
function sleep(ms) { function sleep(ms) {