Chrome Autofill/Autocomplete no value for password

后端 未结 20 1898
逝去的感伤
逝去的感伤 2020-11-27 02:57

When you have saved username and password for some site Chrome will autofill that username and password, but if you try to get the value for the password input field it is e

20条回答
  •  执笔经年
    2020-11-27 03:15

    Another option as of Dec. 16 / Chrome 54

    I can't get the value of the password field, but, after "a short while", I can get the length of the password by selecting it, which is sufficient for me to enable the submit button.

    setTimeout(function() {
      // get the password field
      var pwd = document.getElementById('pwd');
      pwd.focus();
      pwd.select();
      var noChars = pwd.selectionEnd;
      // move focus to username field for first-time visitors
      document.getElementById('username').focus()
      if (noChars > 0) {
        document.getElementById('loginBtn').disabled = false;
      }
    }, 100);
    

提交回复
热议问题