Skip to content

Instantly share code, notes, and snippets.

@turadg
Created April 26, 2011 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turadg/941550 to your computer and use it in GitHub Desktop.
Save turadg/941550 to your computer and use it in GitHub Desktop.
Shim for HTML5 number input type
/* Requires:
* Modernizr <http://www.modernizr.com/>
* JQuery Numeric <http://www.texotela.co.uk/code/jquery/numeric/>
*/
// require numeric input even when HTML5 not available
if (!Modernizr.inputtypes.number) {
// no native support for <input type="number">
$("input[type=number]").numeric(false, function() { alert("Integers only"); this.value = ""; this.focus(); });
}
/* Requires:
* Modernizr <http://www.modernizr.com/>
* JQuery Numeric <http://www.texotela.co.uk/code/jquery/numeric/>
*/
// require numeric input even when HTML5 not available
if (!Modernizr.inputtypes.number) {
// no native support for <input type="number">
$("input[type=number]").numeric(false, function() { alert("Integers only"); this.value = ""; this.focus(); });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment