JavaScript full angle half angle partial _javascript technique

Source: Internet
Author: User
Copy Code code as follows:

<script language=javascript>
Full-width spaces are 12288, half-width spaces are 32
The corresponding relation of the other character half angle (33-126) and the whole angle (65281-65374) is: The difference is 65248
document.write (65281). ToString + "----" + (65374). ToString (+ "----" + (12288). ToString (16));
STRING.PROTOTYPE.DBC2SBC = function ()
{
Return This.replace (/[\uff01-\uff5e]/g,function (a) {return String.fromCharCode (a.charcodeat (0)-65248);}). Replace (/\u3000/g, "");
}
document.write ("ABC 123, we are all good friends". DBC2SBC ());
</script>

Input control
HTML can only be entered in English
Copy Code code as follows:

<input type= "text" onfocus= "this.style.imemode= ' disabled '"/>

Use JS to convert the full angle to half angle (only allow numbers to be entered)
Html
Copy Code code as follows:

<input
Onkeypress= "Var K=event.keycode; Return k>=48&&k<=57 "
Onpaste= "Return!clipboarddata.getdata (' text '). Match (/\d/)"
Ondragenter= "return false" style= "ime-mode:disabled"
>
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.