How do you tell if a browser has auto filled a text-box? Especially with username & password boxes that autofill around page load.
My first question is when does
I was reading a lot about this issue and wanted to provide a very quick workaround that helped me.
let style = window.getComputedStyle(document.getElementById('email'))
if (style && style.backgroundColor !== inputBackgroundNormalState) {
this.inputAutofilledByBrowser = true
}
where inputBackgroundNormalState
for my template is 'rgb(255, 255, 255)'.
So basically when browsers apply autocomplete they tend to indicate that the input is autofilled by applying a different (annoying) yellow color on the input.
Edit : this works for every browser