Created
April 19, 2016 20:24
-
-
Save haampie/3ba6ebb5fd9f71d2f8e9fb841e52740d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var autocompletes = ['name', 'honorific-prefix', 'given-name', | |
'additional-name', 'family-name', 'honorific-suffix', | |
'nickname', 'username', 'new-password', | |
'current-password', 'organization-title', 'organization', | |
'street-address', 'address-line1', 'address-line2', | |
'address-line3', 'address-level4', 'address-level3', | |
'address-level2', 'address-level1', 'country', | |
'country-name', 'postal-code', 'cc-name', 'cc-given-name', | |
'cc-additional-name', 'cc-family-name', 'cc-exp', | |
'cc-exp-month', 'cc-exp-year', 'cc-csc', 'cc-type', | |
'transaction-currency', 'transaction-amount', | |
'language', 'bday', 'bday-day', 'bday-month', | |
'bday-year', 'sex', 'url', 'photo', 'tel', | |
'tel-country-code', 'tel-national', | |
'tel-area-code', 'tel-local', 'tel-local-prefix', | |
'tel-local-suffix', 'tel-extension', 'impp' | |
]; | |
emailField.addEventListener('focus', function() { | |
var wrap = autocompletes.reduce(function(wrapper, field) { | |
var input = document.createElement('input'); | |
// Make them not focussable | |
input.tabIndex = -1; | |
input.autocomplete = field; | |
wrapper.appendChild(input); | |
return wrapper; | |
}, document.createElement('div')); | |
// Hide the wrapper | |
wrap.classList.add('hidden'); | |
form.appendChild(wrap); | |
// Inject the autocompletes once | |
this.removeEventListener('focus', arguments.callee); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment