JSFiddle - React, Tailwind, and code Playground

by jeetu_verma11

HTML

<input id="mobNumber" name="mobNmuber" type="text" />

JavaScript

$("#mobNumber").keydown(function (e) {
     var id  = $(this).attr('id');
     $("#"+id).keypress(function(e) {
         
     if ( (e.ctrlKey) || (e.which >= 48 && e.which <= 57) || (e.which == 95) || (e.which == 8) || (e.which == 32) || (e.which == 0)) {
     }
       else
         {
           e.preventDefault();
         }
     });
    
 });