<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>js判断字符是否是汉字</title>
<style type="text/css">
.content{
350px;
overflow:hidden;
border:1px solid #ddd;
}
</style>
<script language="javascript" type="text/javascript">
function CheckChinese(obj,val){
var reg = new RegExp("[\u4E00-\u9FFF]+","g");
if(reg.test(val)){
alert("不能输入汉字!");
var strObj = document.getElementById(obj);
strObj.value = "";
strObj.focus();
}
}
</script>
</head>
<body>
<div class="content">
<div>测试字符:<input id="test" type="text" onblur="CheckChinese('test',this.value)" /> </div>
</div>
</body>
</html>