I am using these events to try to evaluate form input, but if the form is autofilled by the browser these events don't fire. How can I make the event fire on autofill as well?
I know it's quite old question, but I solved the same problem using e.preventDefault() after the keyup function.
$("#email").keyup(function (e) {
e.preventDefault();
In this way if you select with enter the suggestion by the browser autofill it will notice. The problem still remains when you click with the mouse on the suggestion, but it works fine if you press any key after selected it.
FINAL SOLUTION
I found this post on stackoverflow: https://stackoverflow.com/a/24746108/3481005
and using .on("input") does the trick!
$("#email").on("input",function (e) {
There is no way to detect a browser autofill, unfortunately. Instead, use setInterval
, for example, to run a function at a fairly high frequency that checks whether the original value (or empty) matches the input value and trigger the response that way. If you don't want to do that, you're probably SOL since the browser will not even trigger .change
, and any event is most likely not cross-browser compliant.
You could also have the validation events run on form submission as well, which should be just as effective.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With