Skip to content

Instantly share code, notes, and snippets.

@fatihacet
Created October 3, 2012 14:06
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 fatihacet/3827091 to your computer and use it in GitHub Desktop.
Save fatihacet/3827091 to your computer and use it in GitHub Desktop.
number only field
numericField = function (elementId) {
var allowed = [0, 8];
for (var i = 48; i < 58; i++) {
allowed.push(i);
}
$("#" + elementId).keypress(function(e){
if (!(allowed.indexOf(e.which) >= 0)) {
e.preventDefault();
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment