Keyboard and Chinese input are not allowed but can be clicked

  • 2020-03-30 01:42:15
  • OfStack

The net found a lot of, not practical, not compatible problem, this can!
< Input> Forbidden keyboard and Chinese input, but can not use readonly and also need to be compatible with ie and ff, in order to complete this function took a lot of work, ha ha, in this record for future use; Onpaste ="return false"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">    
<HTML>    
 <HEAD>    
  <TITLE> New Document </TITLE>    
  <script>    
  //Style ="ime-mode:disabled" disables Chinese input & assistance;      
function noPermitInput(e){       
       var evt = window.event || e ;     
        if(isIE()){     
            evt.returnValue=false; //Ie prohibits keyboarding & NBSP;      
        }else{     
            evt.preventDefault(); //Fire fox forbids keyboarding & NBSP;      
        }        
}     
function isIE() {     
    if (window.navigator.userAgent.toLowerCase().indexOf("msie") >= 1)     
        return true;     
    else     
        return false;     
}      
  </script>    
 </HEAD>    
 <BODY>    
   Keyboard key input and Chinese input are prohibited      
  <input type="text" value=""   style="ime-mode:disabled" onkeypress="noPermitInput(event)" >    
 </BODY>    
</HTML>    

Related articles: