Giter Site home page Giter Site logo

erictsai6 / autofill-event Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tbosch/autofill-event

0.0 2.0 0.0 690 KB

A polyfill to fire a change event when the browser auto fills form fields

License: MIT License

Shell 6.88% JavaScript 91.64% CSS 1.49%

autofill-event's Introduction

Build Status

Autofill event polyfill

This is a polyfill that fires change events when browsers autofill form fields without firing a change event. The implementation is generic so it works in any application that uses either jQuery and/or Angular.

Test page with manual tests

Install

  • bower install autofill-event

Usage

Add the script autofill-event.js after jQuery or Angular in your page.

This will do the following:

  • after DOMContentLoaded: check all input fields
  • a field is left: check all other fields in the same form

API (to manually trigger the check):

  • $el.checkAndTriggerAutoFillEvent(): Execute the check for all DOM elements in the given jQuery / jQLite element.

How it works

  1. Remember all changes to input elements by the user (listening for change events) and also by JavaScript (by intercepting $el.val() for jQuery / jQLite elements). That changed value is stored on the element in a private property.

  2. Checking an element for auto fill: Compare the current value of the element with the remembered value. If it's different, trigger a change event.

Dependencies

AngularJS or jQuery (works with either one or both)

Tests

Unit tests (Travis CI)

  1. npm install
  2. bower install
  3. npm install karma -g
  4. Run tests with jQuery: karma start test/unit/config/karma-jquery.conf.js
  5. Run tests with Angular: karma start test/unit/config/karma-angular.conf.js

Manual Tests (live version)

  1. npm install
  2. bower install
  3. scripts/webserver.js
  4. open the manual runner and follow instructions

Notes:

  • They need to be run with a webserver and without iframes, otherwise Chrome would not autofill username/password

autofill-event's People

Contributors

tbosch avatar jca258 avatar blowsie avatar

Watchers

James Cloos avatar Eric Tsai avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.