检测是否全部为中文

发布时间:2007年01月24日      浏览次数:1300 次
<html>
<head>
<title>中国站长天空-网页特效-表单特效-检测是否全部为中文</title>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
<!--把下面代码加到<body>与</body>之间-->
<script language="javascript">
function check()
{
var userName=document.getElementById("userName").value;
if(userName=="")
{
alert("不能为空!")
document.getElementById("userName").focus();
return false;
}
obj=userName.match(/^[\u4e00-\u9fa5]*$/g);
if(obj==null)
{
alert("必须为中文!")
document.getElementById("userName").value="";
document.getElementById("userName").focus();
return false;
}
else
{
alert("全部为中文!")
}
}
</script>
检测是否全部为中文:<input id="userName" type="text">
<input type="button" onclick="check()" value="检测">
</body>
</html>
文章来源:http://www.zzsky.cn/effect/content/873.htm
免责声明:本站相关技术文章信息部分来自网络,目的主要是传播更多信息,如果您认为本站的某些信息侵犯了您的版权,请与我们联系,我们会即时妥善的处理,谢谢合作!