<
script language
=
javascript
>
function
isChineseChar(strInput){
var
len
=
strInput.length;
if
(
0
==
len)
return
false
;
for
(
var
i
=
0
;i
<
len;i
++
){
if
(strInput.charCodeAt(i)
<=
255
)
return
false
;
}
return
true
;
}
alert(isChineseChar(
"
skdj
"
));
alert(isChineseChar(
"
点算法
"
));
alert(isChineseChar(
"
点算法sdf
"
));
</
script
>
正则表达式
<input type="text" onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text', clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))" >