diff --git a/app/templates/profile/signup.html b/app/templates/profile/signup.html index 24849007116bf863f9c3d6018aa9a2a0a6947cfe..7f03243ac1498753ba4936539ffd05e09aa06f1b 100644 --- a/app/templates/profile/signup.html +++ b/app/templates/profile/signup.html @@ -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 %}