当前位置:编程学习 > 网站相关 >>

正则验证输入的是否为中文

·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<title>js验证中文_伴佬</title>  
<mce:script type="text/javascript"><!--  
function CheckPage()  
{  
    var strValue = document.all.ThisInput.value;  
    if (strValue.match(/[^u4e00-u9fa5]/g))  
    {  
        alert("只能输入中文");  
    }  
    else 
    {  
        document.write("通过~<br>");  
        document.write("您输入的是 <font color=green>"+strValue+"</font>");  
    }  
}  
// --></mce:script>  
</head>  
 
<body>  
<form id="form1" action="">  
<center>  
请输入中文:<input type="text" name="ThisInput" id="ThisInput" value="" />  
<input type="button" value="Click" onclick ="CheckPage()"/>  
</center>  
</form>  
</body>  
</html> 

补充:综合编程 , 其他综合 ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,