Skip to content

Instantly share code, notes, and snippets.

@aaronsnoswell
Created September 26, 2012 05:00
Show Gist options
  • Save aaronsnoswell/3786176 to your computer and use it in GitHub Desktop.
Save aaronsnoswell/3786176 to your computer and use it in GitHub Desktop.
Android Webkit <input type="number" /> shim.
// jQuery version
$("input[type='number']").each(function(i, el) {
el.type = "text";
el.onfocus = function(){this.type="number";};
el.onblur = function(){this.type="text";};
});
// Stand-alone version
(function(){ var elms = document.querySelectorAll("input"), i=elms.length;
while(i--) {
var el=elms[i]; if(el.type=="number"])
el.type="text",
el.onfocus = function(){this.type="number";},
el.onblur = function(){this.type="text";};
}
})();
@yoonsy
Copy link

yoonsy commented Jun 23, 2014

👍

@willfire
Copy link

Hello. How I use this function in the input mask with numeric?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment