ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Views/Customer/_CheckUsernameAvailability.cshtml
<script asp-location="Footer">
    $(function () {
        $('#check-availability-button').before('<span id="username-availabilty"></span>');
        $('#Username').bind({
            keydown: function () {
                $('#username-availabilty').text('');
            }
        });
        $('#check-availability-button').click(function () {
            $('#username-availabilty').text('');
            if ($("#Username").val().length > 0) {
                $('#availability-check-progress').show();
                $('#check-availability-button').attr('disabled', 'disabled');

                var postData = {
                    Username: $('#Username').val()
                };
                addAntiForgeryToken(postData);

                $.ajax({
                    cache: false,
                    type: 'POST',
                    url: '@Url.RouteUrl("CheckUsernameAvailability")',
                    data: postData,
                    dataType: 'json',
                    success: function (data) {
                        $('#check-availability-button').removeAttr('disabled');
                        $('#availability-check-progress').hide();
                        $('#username-availabilty').removeAttr('class').attr('class', ((data.Available) ? 'username-available-status text-success d-flex order-2 mt-3' : 'username-not-available-status text-danger d-flex order-2 mt-3'));
                        $('#username-availabilty').text(data.Text);
                    },
                    failure: function () {
                        $('#check-availability-button').removeAttr('disabled');
                        $('#availability-check-progress').hide();
                    }
                });
            } else {
                $('#username-availabilty').attr('class', 'username-not-available-status username-not-available-status text-danger d-flex order-2 mt-3');
                $('#username-availabilty').text('@T("Account.CheckUsernameAvailability.EnterUsername")');
            }
            return false;
        });
    });
</script>
<input type="button" id="check-availability-button" class="btn btn-outline-info check-username-availability-button mt-3" value="@T("Account.CheckUsernameAvailability.Button")" />
<span id="availability-check-progress" style="display: none;" class="please-wait">@T("Common.Wait...")</span>