1. Restricted text boxes cannot be entered in Chinese:
Many times before, I used judgment to write, such as:
Copy Code code as follows:
function nocn (obj)
{
For (I=0;i<document.getelementsbyname ("Text1") [0].value.length;i++)
{
var c = document.getelementsbyname ("Text1") [0].value.substr (i,1);
var ts = escape (c);
if (ts.substring (0,2) = = "%u")
{
Document.getelementsbyname ("Text1") [0].value = "";
Alert ("No Chinese/full-width characters can be entered here");
}
}
}
but few people use ime-mode:disabled (using CSS to turn off text box input)
Ime-mode
Grammar:
Ime-mode:auto | active | Inactive | Disabled
Take value:
Auto: Default value. Does not affect the state of the IME. The same as when the Ime-mode property is not specified
Active: Specifies all characters entered using the IME. The local language input method is activated. User can still undo activation ime
Inactive: Specifies all characters that are not entered using the IME. That is, the non-local language is activated. User can still undo activation ime
Disabled: IME is completely disabled. For controls that have focus (such as an input box), the user cannot activate the IME
So:
<input onpaste= "return false;" type= "text" name= "TextField" style= "ime-mode:disabled" "value=" ">
ime-mode:disabled to disable IME.
Extended:
Copy Code code as follows:
<script language= "JavaScript" >
<!--
function Change (Obutton)
{
var obj = document.all.txt;
if (Obj.style.imeMode = = "Disabled")
{
Obj.style.imeMode = "active";
Obj.value = "";
Obutton.value = "Shielding Chinese Input Method";
}
Else
{
Obj.style.imeMode = "Disabled";
Obj.value = "";
Obutton.value = "Activate Chinese Input Method";
}
}
-->
</SCRIPT>
<input type= "text" name= "TXT" style= "ime-mode:disabled" style= "ime-mode:disabled" >
<input type= "button" value= "Activate Chinese Input Method" onclick= "Change" >
I'm thinking about it, huh?
2. Restricted text boxes cannot be pasted:
Generally see this we will have such a mentality: Disable the CTRL key and C key, and then disable the right button, you can disable the Paste function perfectly.
Then need to write JS file (this JS file this blog has relevant content)
In fact, onpaste= "return false;" can be a perfect implementation to disable paste, but also note that it is disabled is the Paste function, so use this property, even if you can't help the right button, users can not paste content.
So:
Copy Code code as follows:
<input onpaste= "return false;" type= "text" name= "TextField" style= "ime-mode:disabled" "value=" ">
Onpaste to disable pasting.