How to perform a task after autofilling credentials?

1 week ago 5
ARTICLE AD BOX

I set the login button to be enabled only if the email and password are filled in and the email is in the correct format.

function updateLoginButtonState() { const email = usernameInput.value.trim(); const password = passwordInput.value.trim(); const hasEmail = email.length > 0; const hasPassword = password.length > 0; const emailValid = isEmailSyntaxValid(email); loginBtn.disabled = !(hasEmail && hasPassword && emailValid); // NEXT CODE }

The function above is triggered whenever the email and password values ​​are modified and works perfectly fine.

The problem is when the password is filled from the browser's memory. Even if the function is called at the end of DOMContentLoaded, it is not enough.

ChatGPT recommended me to write this at the end

let loginCheckCount = 0; const loginPostLoadCheck = setInterval(() => { updateLoginButtonState(); loginCheckCount++; // max ~2 sekundy (20 × 100 ms) if (loginCheckCount >= 20) { clearInterval(loginPostLoadCheck); } }, 100);

It works correctly, only the specified number is played at given intervals. But it doesn't help, it doesn't affect the button.

Please help

Thank you

Read Entire Article