cmn.php
<script type="text/javascript">
function validate(form){
if(form.uname.value == "")
{
alert("用户名不能为空");
return false;
}
else
{
if(/[^a-zA-Z0-9-_]/.test(form.uname.value))
{
alert("uname could only be a-z, A-Z, 0-9, - and _");
return false;
}
return ture;
}
}
</script>
<table class="signup" cellpadding="2" cellspacing="5" bgcolor="#eeeeee">
<th colspan="2" align="center">注册表单</th>
<form action="cmn.php" method="post" οnsubmit="return validate(this)">
<tr>
<td>用户名</td>
<td><input type="text" name="uname" /></td>
</tr>
<tr>
<td>密码</td>
<td><input type="text" name="upwd" maxlength="20"/></td>
</tr>
<tr><td colspan="2" align="center"><input type="submit" value="注册" /></td></tr>
</form>
</table>
……………………………………