这只是一个页面,完成不了注册的功能。没有数据库,而且提交表单的时候没有链接的页。仅供参考。想演示的可以将下面的代码复制到记事本当中,随便起个名保存,然后将记事本保存的.txt改成.html即可。(如保存的文件叫zhuce.txt改为zhuce.html)
- <html>
- <head>
- <script language=”javascript”>
- function on_submit()
- {
- if (form1.username.value == “”)
- {
- alert(“用户名不能为空,请从新出入!”);
- form1.username.focus();
- return false;
- }
- if (form1.userpassword.value == “”)
- {
- alert(“用密码不能为空,请从新出入!”);
- form1.userpassword.focus();
- return false;
- }
- if (form1.reuserpassword.value == “”)
- {
- alert(“用户确认密码不能为空,请从新出入!”);
- form1.reuserpassword.focus();
- return false;
- }
- if (form1.reuserpassword.value != form1.userpassword.value)
- {
- alert(“两次输入密码不一致,请从新出入!”);
- form1.userpassword.focus();
- return false;
- }
- }
- </script>
- <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
- <title>js练习</title>
- </head>
- <body>
- <form method=”post” name=”form1″ onsubmit=”return on_submit()” action=”xx.xx”>
- 新用户注册:
- 用户名(*):<input type=”text” name=”username” size=”20″ />
- 密码(*): <input type=”password” name=”userpassword” size=”20″ />
- 再次输入密码(*):<input type=”password” name=”reuserpassword” size=”20″ />
- 性 别:<input type=”radio” value=”男” checked name=”sex” />男<input type=”radio” checked name=”sex” value=”女”/>女
- 出生日期: <input name=”year” size=”4″ maxlength=”4″ />年
- <select name=”month”>
- <option value=”1″ selected>1</option>
- <option value=”2″ >2</option>
- <option value=”3″ >3</option>
- <option value=”4″ >4</option>
- <option value=”5″ >5</option>
- <option value=”6″ >6</option>
- <option value=”7″ >7</option>
- <option value=”8″ >8</option>
- <option value=”9″ >9</option>
- <option value=”10″ >10</option>
- <option value=”11″ >11</option>
- <option value=”12″ >12</option>
- </select>月
- <input name=”day” size=”3″ maxlength=”4″ />日
- 家庭住址: <input type=”text” name=”address” size=”20″ />
- <input type=”submit” value=”提交” name=”B1″ /><input type=”reset” value=”重填” name=”B2″ />
- </form>
- </body>
- </html>