Jump to content

Is there a JS / jQ event handler for this


Mahngiel

Recommended Posts

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.

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"

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.