<div class="codetitle"> <span><a style="CURSOR: pointer" data="5369" class="copybut" id="copybut5369" onclick="doCopy('code5369')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code5369"> <br><script language="javascript"> <BR>//全角空格为12288,半角空格为32 <BR>//其他字符半角(33-126)与全角(65281-65374)的对应关系是:均相差65248 <BR>//document.write((65281).toString(16)+"----"+(65374).toString(16)+"----"+(12288).toString(16)); <BR>String.prototype.dbc2sbc = function () <BR>{ <BR>return this.replace(/[\uff01-\uff5e]/g,function(a){return String.fromCharCode(a.charCodeAt(0)-65248);}).replace(/\u3000/g," "); <BR>} <BR>document.write("ABC 123,我们都是好朋友".dbc2sbc()); <BR></script> <br> </div> <br>输入控制 <br>HTML 只能输入英文 <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="97083" class="copybut" id="copybut97083" onclick="doCopy('code97083')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code97083"> <br><input type="text" onfocus="this.style.imeMode='disabled'"> <br> </div> <br>用JS把全角转换成半角(只允许输入数字) <br>HTML <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="75056" class="copybut" id="copybut75056" onclick="doCopy('code75056')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code75056"> <br><input>onkeypress="var k=event.keyCode; return k>=48&&konpaste="return !clipboardData.getData('text').match(/\D/)" <br>ondragenter="return false" style="ime-mode:Disabled" <br>> <br> </div>