Jump to content

Is there a JS / jQ event handler for this


Go to solution Solved by ignace,

Recommended Posts

I could probably figure it out if I knew what to call it. My google-foo has failed.  Is there an event handler for when a user selects an option from their browser's remembered form data?

 

ZhwM.png

 

I've gone through keyup, change, click, blur, and select

 

Cheers!

Link to comment
https://forums.phpfreaks.com/topic/275637-is-there-a-js-jq-event-handler-for-this/
Share on other sites

Considering that would be behavior specifically implemented within each browser and not a valid HTML event, I doubt there is one. You could use onchange to determine when the field is changed, but you wouldn't know if the value entered was manually entered vs. selected from the browser lookup.

  • Solution

tl;dr Browsers do not fire any event when autocompleting the form fields.

 

All I could find is that onchange should be the one to be called, nothing specific for the autocomplete though.

 

I found this:

https://code.google.com/p/chromium/issues/detail?id=42716

 

Which says that in Chrome it should fire the onchange event. The posted example:

http://jsfiddle.net/bevancoleman/6SRYH/

 

Does not appear to fire the onchange event but instead fires the oninput event (chrome, mac), which is the same as onchange?

 

There is a jQuery plugin for this though:

http://furrybrains.com/2009/01/02/capturing-autofill-as-a-change-event/

 

Haven't tried it.

 

Other things I found was:

http://avernet.blogspot.co.at/2010/11/autocomplete-and-javascript-change.html

http://stackoverflow.com/questions/4938242/browser-autofill-and-javascript-triggered-events

 

I searched for "form autocomplete event" and "form autofill event"

Edited by ignace

Aah, yes 'Autofill'.  I appreciate the feedback and useful links, Ignace, truly helpful. 

 

I added input to my bindings and voila (FF 19.0.2) - autofill selection now fires the in response

 

 

    // super generic, over-compensating object mappage
    $( 'form :input' ).map( function () {

        // do something on change
        $( this ).bind( 'keyup change input', function () {

        } );

    } );

 

Isn't that the same as:

$(':input').bind('keyup change input', function() {
  // code here
});

 

For the most part yes. I stripped out the unnecessary info to my issue (depending on use, you'd really want some specificity) . Sorry if that lead to confusion.  Also, one wouldn't want to use :input for this, as it attaches the handlers to submit buttons

Edited by Mahngiel
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.