javascriptwindow吧 关注:23,875贴子:28,004
  • 3回复贴,共1

为什么正则表达式无法判断中文啊

只看楼主收藏回复

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>login.html</title>
<script type="text/javascript">
function custCheck(){
var custName =document.getElementById("custName");
var username =document.getElementById("username");
var code =document.getElementById("code");
if(custName.value==""){
alert("会员名不能为空");
return false;
}
else if(/^[\u4e00-\u9fa5]+$/i.test(custName))
alert("输入的是汉字");
return false;
}
else if(username.value==""){
alert("用户名不能为空");
return false;
}
else if(code.value==""){
alert("密码不能为空");
return false;
}
}
</script>
<style type="text/css">
*,input {font - size:11pt;color:black}
</style>
</head>
<body>
<form action="" method="post" onSubmit="return custCheck()">
企业登录界面:
<table>
<tr><td>会员名:</td>
<td><input type ="text" name="custName" id="custName"></td>
</tr>
<tr><td>用户名:</td>
<td><input type ="text" name="username" id="username"></td>
</tr>
<tr><td>密码:</td>
<td><input type ="password" name="code" id="code"></td>
</tr>
</table>
<input type="submit" value="登录">
</form>
</body>
</html>


1楼2018-03-17 15:13回复
    代码如上 custname中文判断的地方无法判断 求教啊


    2楼2018-03-17 15:13
    回复
      2026-01-27 07:12:25
      广告
      不感兴趣
      开通SVIP免广告
      丁丁


      3楼2018-03-17 15:24
      回复
        不用new RegExp的嘛?


        IP属地:广东来自Android客户端4楼2018-04-19 09:27
        回复