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"
>