首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

判断输入框中是不是包含中文

2012-10-28 
判断输入框中是否包含中文%@ page languagejava contentTypetext/html??? pageEncodingutf-8%

判断输入框中是否包含中文

<%@ page language="java" contentType="text/html"
??? pageEncoding="utf-8"%>
<html>
<head>
<title>Insert title here</title>
</head>
<body>
<script language="javascript">?
function funcChina(){

var obj = document.form1.txtName.value;
if(/.*[\u4e00-\u9fa5]+.*$/.test(obj))
{
alert("含有中文!");
return false;
}
alert("没有中文!");
return true;
}
</script>
<form name="form1">
<input type="text" name="txtName">
<input type="button" name="butTxt" value="开始判断" onclick="funcChina()">
</form>
</body>
</html>

热点排行