这段正则表达式不知道出了什么问题,没有用
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language="JavaScript" type="text/javascript">
function CheckForm() {
var userName = document.getElementById("userName");var re1 ="^[A-Za-z]{1,20}+$";
var password = document.getElementById("password");
var trueName = document.getElementById("trueName");var re3="^[\u4e00-\u9fa5],{0,20}$";
var email = document.getElementById("email");
var re4="^\w+[-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*{1,20}$";
var id = document.getElementById("id");
var re5="^\d{15}$)|(^\d{17}([0-9]|X)$";
var phone=document.getElementById("phone");
var re6="^-?\\d{1,20}+$";
if(!re1.test(userName)){ alert("用户名只能是英文");return false;}
else if(!re3.test(trueName)){alert("姓名只能是中文");return false;}
else if(!re4.test(email)){alert("身份证只能是15或18位数字或字符X");return false;}
else if(!re5.test(id)){alert("邮箱必须包含@");return false;}
else if(!re6.test(phone)){alert("联系电话只包含数字");return false;}
return true;
}
</script>
<style type="text/css">
*,input {
font_size: 11pt;
color: black
}
</style>
</head>
<body>
<form action="welcome.htm" method="post" onSubmit="return CheckForm()">
请输入注册信息:
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="userName" id="userName"></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="password" id="password"></td>
</tr>
<tr>
<td>真实姓名:</td>
<td><input type="text" name="trueName" id="trueName"></td>
</tr>
<tr>
<td>性别:</td>
<td><input type="text" name="sex" id="sex"></td>
</tr>
<tr>
<td>身份证:</td>
<td><input type="text" name="id" id="id"></td>
</tr>
<tr>
<td>籍贯:</td>
<td><input type="text" name="place" id="place"></td>
</tr>
<tr>
<td>邮箱:</td>
<td><input type="text" name="email" id="email"></td>
</tr>
<tr>
<td>联系电话:</td>
<td><input type="text" name="phone" id="phone"></td>
</tr>
</table>
<input type="submit" value="确定"> <input type="reset" value="重置">
</form>
</body>
</html>