JQuery.keyup.keydown.keypress does not detect browser autocomplete

I use these events to try to evaluate the input of the form, but if the form is autocomplete by the browser, these events do not fire. How can I make a fire event autocomplete?

+6
source share
3 answers

Unable to detect browser autocomplete, unfortunately. Instead, use setInterval , for example, to run a function at a fairly high frequency that checks if the original value (or empty) matches the input value and invokes the response this way. If you do not want to do this, you are probably SOL, since the browser does not even run .change , and any event is most likely not compatible with the cross browser.

In addition, you could also conduct form submission checks, which should be just as effective.

+2
source

I know this is a pretty old question, but I solved the same problem using e.preventDefault () after the keyup function.

 $("#email").keyup(function (e) { e.preventDefault(); 

Thus, if you select autofill with a browser offer, enter will notice. The problem remains when you click on the tooltip, but it works fine if you press any key after selecting it.

FINAL DECISION

I found this post on stackoverflow: fooobar.com/questions/190967 / ...

and using .on ("enter") does the trick!

 $("#email").on("input",function (e) { 
+2
source

You can fake the desired behavior a bit by .click() to .click() and / or .dblclick() .

This is not guaranteed, but you can catch an additional mouse click if they decide to "approve" autocomplete by selecting it in the field.

0
source

Source: https://habr.com/ru/post/915860/


All Articles