SoFunction
Updated on 2025-04-09

Restricted text boxes based on js implementation can only enter numbers

Without further ado, just attach the source code for reference only

Encapsulated, if you want to use it, just call the getEvent function below

function getEvent() {
 if () {
  return ; //for ie
 }
 func = ;
 while (func != null) {
  var arg0 = [0];
  if (arg0) {
  if (( == Event ||  == MouseEvent) || (typeof (arg0) == "object" &&  && )) {
     return arg0;
   }
  }
  func = ;
 }
 return null;
 };
 
 function doit(){
  var ev = getEvent();
  if( < 8) {return false;}
  else if( > 8 &&  < 48) {return false;}
  else if( > 57 &&  <96) {return false;}
  else if( > 105) {return false;}
  else {return true;}
 };

The above is all the content of this article. I hope it will be helpful to everyone. I also hope to support me more!