Skip to content

Instantly share code, notes, and snippets.

@greyaperez
Created September 30, 2013 15:16
Show Gist options
  • Save greyaperez/6765317 to your computer and use it in GitHub Desktop.
Save greyaperez/6765317 to your computer and use it in GitHub Desktop.
Clears Non-Numeric Chars with Each Keystroke
// FN Input Numbers Only
$.fn.inputNumOnly = function(){
$(this).each(function(){
$this = $(this);
$this.keyup(function(){
var fieldVal = $this.val();
if(fieldVal.search(/[^0-9?]/gi) > -1){ $this.val(fieldVal.replace(/[^0-9?]/gi,"")); }
});
return this;
});
} // [eo] FN Input Numbers Only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment