Skip to content

Instantly share code, notes, and snippets.

@maniaks
Created May 18, 2015 13:04
Show Gist options
  • Save maniaks/598fe9a522d8b2bc278b to your computer and use it in GitHub Desktop.
Save maniaks/598fe9a522d8b2bc278b to your computer and use it in GitHub Desktop.
Only digits in input Text - From http://jsfiddle.net/lesson8/HkEuf/1/
$(document).ready(function () {
//called when key is pressed in textbox
$("#quantity").keypress(function (e) {
//if the letter is not digit then display error and don't type anything
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//display error message
$("#errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment