博客列表 >简单制作一个用户注册表单

简单制作一个用户注册表单

黑夜家的一只猫
黑夜家的一只猫原创
2023年03月14日 17:09:41318浏览

通过表单制作一个用户注册表

用户注册表如下:

用户注册表代码如下:

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>表单元素-注册</title>
  8. </head>
  9. <body>
  10. <form action="register.php" method="post">
  11. <fieldset style="display: inline-grid; gap: 1em">
  12. <legend>新用户注册</legend>
  13. <div class="username">
  14. <label for="uname">用户名:</label>
  15. <input type="text" id="uname" name="uname" value="" placeholder="请输入用户名/手机号" autofocus required />
  16. </div>
  17. <div class="email">
  18. <label for="email">邮箱:</label>
  19. <input type="email" name="email" id="email" placeholder="admin@email.com" required />
  20. </div>
  21. <div class="psw">
  22. <label for="psw">密码:</label>
  23. <input
  24. type="password"
  25. onkeydown="this.nextElementSibling.disabled=false"
  26. name="password"
  27. id="psw"
  28. required
  29. placeholder="不少于6位且不能全为数字"
  30. />
  31. <button type="button" onclick="showPsw(this, this.form,true)" disabled>查看</button>
  32. </div>
  33. <div class="rfm">
  34. <label for="">安全问题:</label>
  35. <select id="pasans" name="questionid" >
  36. <option selected disabled>安全问题(未设置请忽略)</option>
  37. <option value="0" >你个人计算机的型号</option>
  38. <option value="1" >你宠物的名字</option>
  39. <option value="2" >你最喜欢的餐馆的名称</option>
  40. <option value="3" >你最喜欢的水果</option>
  41. <option value="4" >你最喜欢的城市</option>
  42. <option value="5" >你最喜欢的一首歌</option>
  43. </select>
  44. </div>
  45. <div class="rfm" id="pasans" style="">
  46. <table>
  47. <tbody>
  48. <tr>
  49. <th>答案:</th>
  50. <td><input type="text" name="answer" id="pasans" size="30" class="px p_fre" ></td>
  51. </tr>
  52. </tbody>
  53. </table>
  54. </div>
  55. <div>
  56. <legend>个人信息填写</legend>
  57. <div class="age">
  58. <label for="age">年龄:</label>
  59. <input type="number" id="age" name="age" min="12" max="80" />
  60. </div>
  61. <div class="birthday">
  62. <label for="birthday">生日:</label>
  63. <input type="date" id="birthday" value="2000-01-01" name="birthday" min="1949-10-01" />
  64. </div>
  65. <div class="sex">
  66. <label for="male">性别:</label>
  67. <input type="radio" name="sex" value="male" id="male" checked /><label for="male"></label>
  68. <input type="radio" name="sex" value="female" id="female" /><label for="female"></label>
  69. <input type="radio" name="sex" value="secret" id="secret" /><label for="secret">保密</label>
  70. </div>
  71. <div class="hobby">
  72. <label>爱好:</label>
  73. <input type="checkbox" name="hobby[]" value="trave" id="trave" /><label for="trave">旅游</label>
  74. <input checked type="checkbox" name="hobby[]" value="program" id="programe" /><label for="program"
  75. >编程</label
  76. >
  77. <input type="checkbox" name="hobby[]" value="shoot" id="shoot" /><label for="shoot">摄影</label>
  78. <input checked type="checkbox" name="hobby[]" value="game" id="game" /><label for="game">游戏</label>
  79. </div>
  80. <div class="edu">
  81. <label for="">学历:</label>
  82. <select name="edu" id="">
  83. <option value="1">小学</option>
  84. <option value="2">中学</option>
  85. <option value="3" selected>大学</option>
  86. <option value="4">博士</option>
  87. </select>
  88. </div>
  89. </div>
  90. <button>提交</button>
  91. </fieldset>
  92. </form>
  93. <script >
  94. function showPsw(ele,form){
  95. const psw = form.password
  96. if (psw.type === 'password'){
  97. psw.type = 'text'
  98. ele.textContent = '隐藏'
  99. } else if (psw.type === 'text'){
  100. psw.type = 'password'
  101. ele.textContent = '显示'
  102. } else {
  103. return false
  104. }
  105. }
  106. </script>
  107. </body>
  108. </html>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议