日期:2014-05-16  浏览次数:20364 次

js全角半角转换
前半角分类

包括所有的字符和数字
onkeyup="javascript:var t = ''; with(this.value) { for (var i = 0; i < length; i++) t += (65248 <= charCodeAt(i) && charCodeAt(i) <= 65375) ? String.fromCharCode(charCodeAt(i) - 65248) : charAt(i); } this.value = t;"


所有的全角数据替换成半角数字
onkeyup="javascript:var t = ''; with(this.value) { for (var i = 0; i < length; i++) t += (65296 <= charCodeAt(i) && charCodeAt(i) <= 65305) ? String.fromCharCode(charCodeAt(i) - 65248) : charAt(i); } this.value = t;"