Some restrictions on the text box control summary ~~_ form effects

Source: Internet
Author: User
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.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.