How to determine when a browser enters a saved password into a web login

I have a website that detects when a username and password are entered, and then includes a login button. The problem is that the browser enters the username and password that it remembered, and then the login button is never turned on. Is there a way in JavaScript to detect a browser entering this information?

+6
javascript browser
source share
4 answers

You can poll it with setInterval() , but why do you want it to be disabled before all data has been entered?

This does not seem to be a widespread practice.

+4
source share

Alternatively, you can leave the button turned on and check for non-empty input when pressed. This would be more standard, as others have pointed out.

+4
source share

Did not check it, but you can use the onchange event in text fields.

0
source share

At first, as mentioned above, I'm not sure why you would not enable it by default. But here is what you need to do. When the page loads, just check to see if there is anything in the fields. Sometimes the browser enters login information when the fields have focus, but I assume that if it has focus, your script may detect the input.

 window.onload=function(){ var txt=document.getElementById('username'); if(txt!==''){showSubmit();} //if you have a preset value you can always do txt!=='username' } 
0
source share

All Articles