js关于中文的判断
<script language="javascript">
function funcChina(){
var obj = document.form1.txtName.value;
if(/.*[\u4e00-\u9fa5]+.*$/.test(obj))
{
alert("不能含有汉字!");
return false;
}
return true;
}
</script>
<form name="form1">
<input type="text" name="txtName"><input type="button" name="butTxt" value="判断是否是汉字" onclick="funcChina()">
</form>
<script language="javascript">
function isChina(s){
var patrn=/[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/gi;
if(!patrn.exec(s)){
return false;
}
else{
return true;
}
}
</script>