0
点赞
收藏
分享

微信扫一扫

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

<%@ 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="开始判断" οnclick="funcChina()">
</form>
</body>
</html>

举报

相关推荐

0 条评论