tbosch / autofill-event

A polyfill to fire a change event when the browser auto fills form fields
MIT License
383 stars 53 forks source link

update on input events #33

Open stevegal opened 8 years ago

stevegal commented 8 years ago

Chrome fires input events on autofill for things like username, so listen for these and resync.

Chrome doesn't allow password fields to be read in javascript before user interaction, so look for these and fire an autoFilled event on the element if this has happened.

bettysteger commented 8 years ago

hmm I tried your code, but it is still not working the password field is not filled (before user interaction)

stevegal commented 8 years ago

Sorry i didn't make it clear, but if you want to pre-empt chrome filling in the value, your element must listen to the "autofilled" event I fire, then take appropriate action. Chrome will not allow us to read the value before user interaction, but we can get informed that it has autofilled. Not quite as seemless as tbosh, but now you can action.

stevegal commented 8 years ago

To be a bit more precise, you have to "element.bind('autoFilled',callback)" where callback defines what you want to do when a browser autofilled and hasn't yet updated the model. Apologies again, if this was not clear.