本帖最后由 黄杨 于 2013-3-27 01:16 编辑
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>注册</title>
<style type="text/css">
.center {
text-align: center;
}
.red {
color: #F00;
}
</style>
<script language="javascript">
function on_submit() {
if (form1.username.value == "") {
alert("用户名不能为空!请输入用户名!");
form1.username.focus();
return false;
}
if (form1.passward.value == "") {
alert("用户密码不能为空!请输入用户密码!");
form1.passward.focus();
return false;
}
if (form1.email.value.length != 0) {
for (i = 0; i < form1.email.value.length; i++) {
if (form1.email.value.charAt(i) == "@") {
break;
}
}
if (i == form1.email.value.length) {
alert("输入的电子邮箱地址非法!请重新输入!");
form1.email.focus();
return false;
}
} else {
alert("电子邮箱不能为空!请输入电子邮箱!");
form1.email.focus();
return false;
}
}
</script>
</head>
<body>
<form method="post"
enctype="multipart/form-data" name="form1"
>
<table width="100%" border="0">
<tr>
<td colspan="2" class="center">用户注册</td>
</tr>
<tr>
<td width="11%">用户名:<span class="red">(*)</span></td>
<td width="89%"><input type="text" name="username"></td>
</tr>
<tr>
<td>密 码:<span class="red">(*)</span></td>
<td><input name="password" type="password"></td>
</tr>
<tr>
<td>电子邮箱:<span class="red">(*)</span></td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>家庭住址:</td>
<td><input type="text" name="address"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" id="button"
value="提交"> <input type="reset" name="button2" id="reset"
value="重置"></td>
</tr>
</table>
</form>
</body>
</html>
弄了好久不懂哪里出错了,郁闷。。。
上面只能验证用户名是否为空,其他的出问题
|