I have a login form, when the page is opened, Chrome automatically fills the credentials. However, onChange
event of input
elements are not being triggered.
Clicking anywhere on the page makes them registered in value
attribute of the input
, which is what we need. I tried doing event.target.click()
, that did not help.
In the onChange I set the values into state like:
this.setState({ email: event.target.value })
And the submit button is disabled if email.length === 0
.
So even if page shows that credentials are filled, submit button still looks disabled.
Since clicking anywhere registers the values, clicking the submit button also registers them before submitting. So it works perfectly.
It is not about timing though, field is never being filled. When I open the Developer Console and check, the value field is empty, until I click somewhere.
Only issue here is that the button looks disabled because email input value is empty until something is clicked. Is there a hacky solution for this?