Skip to content
Snippets Groups Projects
Commit 2e61b9d8 authored by Ethan-clay03's avatar Ethan-clay03
Browse files

Added delay to search if username/email is available

parent b0c5edae
No related branches found
No related tags found
No related merge requests found
......@@ -71,12 +71,21 @@
makeAjaxRequest("{{ url_for('profile.check_email') }}", { 'email': email }, 'email');
}
document.getElementById('username').addEventListener('blur', function () {
function delayAvailabilityCheck(func, delay) {
let timer;
return function(...args) {
clearTimeout(timer);
timer = setTimeout(() => func.apply(this, args), delay);
};
}
document.getElementById('username').addEventListener('input', delayAvailabilityCheck(function () {
checkUsernameAvailability(this.value);
});
}, 500));
document.getElementById('email').addEventListener('blur', function () {
document.getElementById('email').addEventListener('input', delayAvailabilityCheck(function () {
checkEmailAvailability(this.value);
});
}, 500));
</script>
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment