<!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"/>男
<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="mail" size="17"/></td></tr>
<tr><td class="one">请输入有效邮箱</td></tr> <tr>
<td class="one"><input type="submit" name="regist" value="注册"/></td>
<td class="one"><input type="reset" name="reset" value="重置"/>
<input type="button" value="返回" onclick="window.location='index.php';"/>
</td>
</tr>
</table>
</form>
</body>
</html>
用户名验证是否为空时可以,加上正则验证时就出错了?
新手学习,不知道怎么错了求解并改正
<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"/>男
<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="mail" size="17"/></td></tr>
<tr><td class="one">请输入有效邮箱</td></tr> <tr>
<td class="one"><input type="submit" name="regist" value="注册"/></td>
<td class="one"><input type="reset" name="reset" value="重置"/>
<input type="button" value="返回" onclick="window.location='index.php';"/>
</td>
</tr>
</table>
</form>
</body>
</html>
用户名验证是否为空时可以,加上正则验证时就出错了?
新手学习,不知道怎么错了求解并改正
解决方案 »
- coolite(ext.net) store怎么绑定复杂类型,怎么替换信息
- 请高手指点一下这个正则怎么写?
- 怎么让它等于文本节点?
- <input type=button onclick="">中调用两个函数
- 点击链接保存图片,换了firefox就不好用了.
- 为什么我的javascript代码在网面里运行正常,可如果用<script src="asdf.js" language="javascript></script>就不行了?
- 大家都进来看看吧,javascript中有这种内置对象吗?
- 请问高手关于按件事件(稍难)
- 一个简单得问题,如何让文本框在打开页面是不可见?
- Jquery 复选框批量设值问题
- 这里的arguments在什么情况下可以用到?
- 关于jquery得到列表id的问题
这个有错··
var patten=/^\w+$/;