function cc() {
var str = document.getElementById('checkcode').value
var result=''
if (str.length<=0) {return false}
for(var i=0i<str.lengthi++)
{
if(str.charCodeAt(i)>125)
{
result += String.fromCharCode(str.charCodeAt(i)-65248)
} else{
result = str
}
}
document.getElementById('checkcode').value = result
}
</script>
<input class="yanzheng" id="checkcode" type="text" onblur="cc()"/>
字母和数字都可以转过来,文本框失去焦点时转换
有个缺点,输入汉字后就会转换成乱码
用js:function ConvertToBJ(obj)
{
var str=obj.value
var result=""
for (var i = 0i <str.lengthi++)
{
if (str.charCodeAt(i)==12288)
{
result+= String.fromCharCode(str.charCodeAt(i)-12256)
continue
}
if (str.charCodeAt(i)>65280 &&str.charCodeAt(i)<65375)
result+= String.fromCharCode(str.charCodeAt(i)-65248)
else result+= String.fromCharCode(str.charCodeAt(i))
}
obj.value=result
}