$('.register_button').click(async function (e) {
    e.preventDefault();
    $(this).attr('disabled', 'disabled');

    let form = $('.register_form'),
        data = new FormData(form[0]),
        url = form.attr('action'),
        method = form.attr('method');

    const response=await ajax({
        url,
        data,
        dataType: 'json',
        method,
        contentType: false,
        processData: false,
    });

    if (response.errors) {
        $(this).removeAttr('disabled');
        toasterError(response.errors);
    }
    if (response.url) {
        window.location.href = response.url;
    }
});

$('#togglePassword').click(function() {
    const password = $('#password'),
        type = password.attr('type') === 'password' ? 'text' : 'password';
    password.attr('type', type);
    $(this).toggleClass('fa-eye-slash');
});
