日期:2014-05-16  浏览次数:20421 次

JS正则验证问题
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>程序设计教学辅导网站个人信息注册</title>
<script type="text/javascript">
<!--
function check()
{
var c_user= document.getElementById("user");
var c_psword=document.getElementById("psword");
var c_conpsword=document.getElementById("conpsword");
var c_name=document.getElementById("name");
var c_tel=document.getElementById("tel");
var c_mail=document.getElementById("mail");
var patten="^\w+$";
if (!patten.test(c_user)||c_user.value=="")
{
alert("用户名不合法");
c_user.focus();
return false;
}
return true;
}
//-->
</script>
<style type="text/css">
body{text-align:center;}
td.one{text-align:left;}
td.two{text-align:right;}
form{margin-botton:0px;}
</style>
</head>
<body>
<form action="control/register.php" method="post" name="form_regist" onsubmit="return check()">
 <table border="1" align="center" width="300px">
 <caption><b>新用户个人信息注册</b></caption><br><br>
</tr>
 <tr><td rowspan="2" class="one">用户名:</td>
  <td class="one"><input type="text" id="user" name="user" size="17" maxlength="14"/></td>
 </tr
 <tr>
  <td class="one">不超过14位(字母,数字)</td>
 </tr>
 
 <tr>
  <td rowspan="2" class="one">密码:</td>
  <td class="one"><input type="password" name="psword" size="17" maxlength="14"/></td></tr>
 <tr>
 <td class="one">不区分大小写,密码长度6~14位</td>
</tr>
 <tr><td rowspan="2" class="one">确认密码:</td>
  <td class="one"><input type="password" name="conpsword" size="17" maxlength="14"></td></tr>
<tr>
<td class="one">再次输入密码</td></tr>

 <tr><td rowspan="2" class="one">姓名:</td><td class="one"><input type="text" name="name" size="17"/></td></tr>
<tr>
<td class="one">请使用真实姓名</td></tr>
 <tr><td class="one">性别:</td><td><input type="radio" checked="checked" name="sex" value="male"/>男&nbsp;
  <input type="radio" name="sex" value="female"/>女</td></tr>
 <tr>
  <td rowspan="2" class="one">联系手机:</td>
  <td class="one"><input type="text" name="tel" size="17"/></td></tr>
<tr><td class="one">11位</td></tr>

 <tr><td rowspan="2" class="one">邮箱:</td><td class="one"><input type="text" name