如何用正则呀,不会,我想账号密码只能(A-Z,0-9)混合一起,不限制开头用字母或数字,开头可以大小写或者数字,(不能纯数字或字母)
账号密码要(最少要6-15字符串长度)<?php
include "comm.php";
?>
<!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=gb2312">
<title>无标题文档</title>
</head>
<link rel="stylesheet" type="text/css" href="css.css">
<body>
<script type="text/javascript">
function check(){
if(myform.username.value==""){
alert("用户名不能为空!");
return false;
}
if(myform.pw.value==""|myform.pw1.value==""){
alert("密码不能为空!");
return false;
}
if(myform.pw.value!=myform.pw1.value){
alert("两次输入的密码不一致!")
return false;
}
return true;
}
</script>
<?php if(isset($_POST['username'])){
$user = $_POST['username'];
$pw = md5($_POST['pw1']);
$conn = mysql_connect("localhost","root","123456");
mysql_select_db("e7");
$sql = "insert into e7_user (user_name,pw) values('$user','$pw')";
mysql_query("set names 'gb2312'");
mysql_query($sql,$conn);
mysql_close($conn);
get_show_msg("index.htm","注册成功");
}
?>
<div id="warp">
<div id="head"></div>
<div id="mainbav">
<ul>
<li><a href="index.htm">首页</a></li>
</ul>
</div>
<div id="content">
<div class="conte">
<form action="" method="post" id="myform" name="myform" onsubmit="return check();">
<table width="600" height="300" border="1" cellspacing="1" cellpadding="1" align="center">
<tr>
<td align="center">游戏账号注册</td>
</tr>
<tr>
<td> 账号注册:<input type="text" name="username" id="username"></td>
</tr>
<tr>
<td> 密码:<input type="password" name="pw" id="pw"></td>
</tr>
<tr>
<td>再次确定密码:<input type="password" name="pw1" id="pw1"></td>
</tr>
<tr>
<td align="center"><input type="submit" id="sub" value="确定"></td>
</tr>
</table>
</form>
</div>
</div>
</div>
</body>
</html>
账号密码要(最少要6-15字符串长度)<?php
include "comm.php";
?>
<!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=gb2312">
<title>无标题文档</title>
</head>
<link rel="stylesheet" type="text/css" href="css.css">
<body>
<script type="text/javascript">
function check(){
if(myform.username.value==""){
alert("用户名不能为空!");
return false;
}
if(myform.pw.value==""|myform.pw1.value==""){
alert("密码不能为空!");
return false;
}
if(myform.pw.value!=myform.pw1.value){
alert("两次输入的密码不一致!")
return false;
}
return true;
}
</script>
<?php if(isset($_POST['username'])){
$user = $_POST['username'];
$pw = md5($_POST['pw1']);
$conn = mysql_connect("localhost","root","123456");
mysql_select_db("e7");
$sql = "insert into e7_user (user_name,pw) values('$user','$pw')";
mysql_query("set names 'gb2312'");
mysql_query($sql,$conn);
mysql_close($conn);
get_show_msg("index.htm","注册成功");
}
?>
<div id="warp">
<div id="head"></div>
<div id="mainbav">
<ul>
<li><a href="index.htm">首页</a></li>
</ul>
</div>
<div id="content">
<div class="conte">
<form action="" method="post" id="myform" name="myform" onsubmit="return check();">
<table width="600" height="300" border="1" cellspacing="1" cellpadding="1" align="center">
<tr>
<td align="center">游戏账号注册</td>
</tr>
<tr>
<td> 账号注册:<input type="text" name="username" id="username"></td>
</tr>
<tr>
<td> 密码:<input type="password" name="pw" id="pw"></td>
</tr>
<tr>
<td>再次确定密码:<input type="password" name="pw1" id="pw1"></td>
</tr>
<tr>
<td align="center"><input type="submit" id="sub" value="确定"></td>
</tr>
</table>
</form>
</div>
</div>
</div>
</body>
</html>
alert("密码长度不符!")
return false;
}
if(/^\d+$/.test(myform.pw.value) || /^[a-z]+$/i.test(myform.pw.value)){
alert("不能是纯数字或字母")
return false;
}
if(!/^\w+$/.test(myform.pw.value)){
alert("密码不符")
return false;
}
..............