var inputs = document.getElementsByTagName('input');
for (var i = 0; i < inputs.length; i++) {
inputs[i].onfocus = foo;
}
function foo(){
alert(this.value);
}
When the input values are manually entered:
Above code works and alerts the correct values regardless of the type of an input field.
When the input values auto-filled by browser:
Code works and alerts the correct values when the input field is of type text. In case of a password field, it alerts empty string!
Is this behaviour because of the browser's security policies? Or there's any workaround possible? I tried it in Chrome browser.