Answers for "enter only digits in textbox using javascript jsfiddle"

0

enter only digits in textbox using javascript jsfiddle

Number : <input type="text" name="quantity" id="quantity" />&nbsp;<span id="errmsg"></span>


<script>
  
 $(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;
    }
   });
});
 </script>
Posted by: Guest on July-26-2021

Code answers related to "enter only digits in textbox using javascript jsfiddle"

Code answers related to "Javascript"

Browse Popular Code Answers by Language