1Number : <input type="text" name="quantity" id="quantity" /> <span id="errmsg"></span>
2
3
4<script>
5
6 $(document).ready(function () {
7 //called when key is pressed in textbox
8 $("#quantity").keypress(function (e) {
9 //if the letter is not digit then display error and don't type anything
10 if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
11 //display error message
12 $("#errmsg").html("Digits Only").show().fadeOut("slow");
13 return false;
14 }
15 });
16});
17 </script>