Skip to content

Instantly share code, notes, and snippets.

@mikbox74
Created April 3, 2019 18:45
Show Gist options
  • Save mikbox74/d3aa4775ebd31597ec39479e322bf33e to your computer and use it in GitHub Desktop.
Save mikbox74/d3aa4775ebd31597ec39479e322bf33e to your computer and use it in GitHub Desktop.
Unputmask + autofill
jQuery(function(){
//autofill event hack
$('input.phone').one('animationstart', function(e, f) {
var animationName = e.originalEvent.animationName;
console.log(animationName);
if (animationName == 'onAutoFillCancel') {
$(this).inputmask("+7 (999) 999-99-99");
}
});
});
//autofill event hack
@keyframes onAutoFillStart { from {/**/} to {/**/}}
@keyframes onAutoFillCancel { from {/**/} to {/**/}}
input.phone:-webkit-autofill {
// Expose a hook for JavaScript when autofill is shown
// JavaScript can capture 'animationstart' events
animation-name: onAutoFillStart;
// Make the background color become yellow really slowly
transition: background-color 50000s ease-in-out 0s;
}
input.phone:not(:-webkit-autofill) {
// Expose a hook for JS onAutoFillCancel
// JavaScript can capture 'animationstart' events
animation-name: onAutoFillCancel;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment