Find a lot on the Internet, not practical, or compatibility issues, this can!
<input> prohibit 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 cost a lot of Kung Fu, hehe, in this record for future use; also prohibit pasting onpaste= "return false"
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
Style style= "ime-mode:disabled" Prohibit Chinese input
function Nopermitinput (e) {
var evt = window.event | | E
if (Isie ()) {
Evt.returnvalue=false; IE prohibits keyboard input
}else{
Evt.preventdefault (); Fire Fox prohibits keyboard input
}
}
function Isie () {
if (Window.navigator.userAgent.toLowerCase (). IndexOf ("MSIE") >= 1)
return true;
Else
return false;
}
</script>
</HEAD>
<BODY>
Disable keyboard key input and Chinese input
<input type= "text" value= "style=" ime-mode:disabled "onkeypress=" Nopermitinput (event) >
</BODY>
</HTML>