0

My objective is to fire a web event whenever my client fills in his form using google chrome's autofill feature (https://developers.google.com/web/updates/2015/06/checkout-faster-with-autofill).

I believe this is not possible unless google provides a plugin/api out-of-box which indicates that the autofill profile existed and has been chosen by the user to fill in his form. Can peers throw more light on this?

[Edit] Please note that this auto fill (by chrome) is user triggered, rather than the ones which we usually see browsers doing (like username/password, which happens at page load). Hence, the java script solution as prescribed in many other answers may not work here. My questions is very specific to the autofill profile which google chrome maintains, to help people checkout forms faster.

wscourge
  • 10,657
  • 14
  • 59
  • 80
Yo Yo Money Singh
  • 679
  • 3
  • 11
  • 22

1 Answers1

0

From this article:

Workarounds

The bottom line is that your JavaScript code can't rely on the change event. If your code needs to know when the value of a field changes, you have two choices:

  1. Have some JavaScript code that runs at a regular interval, checks the value of all the fields, and calls your change handler when it notices that a value has changed.
  2. Disable autocomplete by adding autocomplete="off" on the element. This technique has been supported by browsers since IE 5 (March 1999) and Netscape 6.2 (October 2001), and now made its way into HTML5.

The interval solution (1) seems pretty nice, as safe interval time in HTML5 is 4ms, reffering to this question.

So you can probably assume that filling one input in 4ms is filling it by hand, and filling more than one is autofill.

Community
  • 1
  • 1
wscourge
  • 10,657
  • 14
  • 59
  • 80
  • I believe the suggested solution only classifies between human and automated filling of data. However, it may not be able call out whenever a selenium script is filling in a form, instead of chrome autofill (selenium script can have a tremendous speed of form filling). Just thinking if there is a specific way by which we can be sure that the form is being autofilled BY chrome autofill feature only. – Yo Yo Money Singh Feb 14 '17 at 12:55