- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>表单特效-判断文本框内是否包含中文</title>
- <meta http-equiv="content-type" content="text/html;charset=gb2312">
- </head>
- <body>
- <!--把下面代码加到<body>与</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>

