博客列表 >用户注册表单

用户注册表单

vbokok
vbokok原创
2023年01月17日 17:13:49277浏览
  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: 0.8em">
  12. <legend>用户注册</legend>
  13. <!-- 文本控件 -->
  14. <div class="user">
  15. <label for="uname">用户名:</label>
  16. <!-- required:必填 -->
  17. <input type="text" name="my_user" id="unmae" placeholder="请输入用户名" required>
  18. </div>
  19. <div class="my-email">
  20. <label for="zc-email">邮箱:</label>
  21. <input type="email" name="my_email" id="zc-email" placeholder="XXX@email.com" required>
  22. </div>
  23. <!-- 数值控件 -->
  24. <div class="passw">
  25. <label for="passw">密码:</label>
  26. <input type="password" name="password" id="passw" placeholder="不少于6位" required onkeydown="this.nextElementSibling.disabled=false">
  27. </label>
  28. <button type="button" disabled onclick="showPsw(this,this.form)">显示</button>
  29. </div>
  30. <div class="age">
  31. <label for="age">年龄:</label>
  32. <input type="number" name="age" id="age" min="25" max="55">
  33. </div>
  34. <div class="birthday">
  35. <label for="birthday">生日:</label>
  36. <input type="date" name="birthday" id="birthday" value="1998-01-01" min="1978-01-01" max="1998-01-01">
  37. </div>
  38. <!-- url控件 -->
  39. <div class="url">
  40. <label for="blog">博客:</label>
  41. <input type="url" name="url" id="blog" placeholder="http://">
  42. </div>
  43. <!-- 拾色器 -->
  44. <div class="color">
  45. <label for="color">背景:</label>
  46. <input type="color" name="color" id="color" value="#fff111">
  47. </div>
  48. <!-- 搜索框,跟文本框比多一个清空按钮 -->
  49. <div class="search">
  50. <label for="keywords">搜索:</label>
  51. <input type="search" name="keywords" id="keywords" placeholder="请输入您要查询的关键字">
  52. </div>
  53. <!-- 文件上传 -->
  54. <div class="upload">
  55. <label for="upload">头像:</label>
  56. <input type="file" name="userpic" id="upload">
  57. <button type="button" onclick="fileUploads(this.form)">上传</button>
  58. </div>
  59. <!-- 单选按钮 -->
  60. <!-- checked为布尔属性,为默认选项 -->
  61. <div class="gender">
  62. <label for="male">性别:</label>
  63. <input type="radio" name="gender" value="male" id="male" checked><label for="male"></label>
  64. <input type="radio" name="gender" value="famale" id="female"><label for="famale"></label>
  65. </div>
  66. <!-- 多选按钮 -->
  67. <div class="hobby">
  68. <label>爱好</label>
  69. <!-- 多选时name:必须为hobby[],否则 只有一个值 -->
  70. <input type="checkbox" name="hobby[]" id="game" value="game" checked><label for="game">游戏</label>
  71. <input type="checkbox" name="hobby[]" id="travel" value="travel" checked><label for="travel">旅游</label>
  72. <input type="checkbox" name="hobby[]" id="shoot" value="shoot"><label for="shoot">摄影</label>
  73. <input type="checkbox" name="hobby[]" id="film" value="film"><label for="film">电影</label>
  74. </div>
  75. <div class="edu">
  76. <label for="edu">学历:</label>
  77. <!-- 下拉列表里的键与值是分离的 -->
  78. <select name="edu" id="">
  79. <option value="" selected disabled>--请选择---</option>
  80. <option value="0">文盲</option>
  81. <optgroup label="义务教育">
  82. <option value="1">小学</option>
  83. <option value="2">初中</option>
  84. <option value="3">高中</option>
  85. </optgroup>
  86. <optgroup label="高等教育">
  87. <option value="4">专科</option>
  88. <option value="5">本科</option>
  89. <option value="6">硕士</option>
  90. <option value="7">博士</option>
  91. </optgroup>
  92. </select>
  93. </div>
  94. <!-- 预置值列表 -->
  95. <!-- input.list与datalist.id进行绑定 -->
  96. <div class="like">
  97. <label for="keyword">所学语言:</label>
  98. <input type="search" name="language" list="details" id="keywords">
  99. <datalist id="details">
  100. <option value="html">html</option>
  101. <option value="css">css</option>
  102. <option value="js">js</option>
  103. <option value="php">php</option>
  104. <option value="c++">c++</option>
  105. <option value="node">node</option>
  106. </datalist>
  107. </div>
  108. <!-- 文本框:多行文本 -->
  109. <div>
  110. <label for="comment">备注:</label>
  111. <!-- textarea:没有value属性,它的值在textarea标签之间 -->
  112. <textarea name="comment" id="comment" cols="30" rows="10" maxlength="100" style="resize: none;">
  113. 请输入备注内容
  114. </textarea>
  115. </div>
  116. <button type="submit">提交注册</button>
  117. </fieldset>
  118. </form>
  119. <script>
  120. function showPsw(ele, form) {
  121. const psw = form.password
  122. if (psw.type === 'password') {
  123. psw.type = 'text'
  124. ele.textContent = '隐藏'
  125. } else if (psw.type === 'text') {
  126. psw.type = 'password'
  127. ele.textContent = '显示'
  128. } else {
  129. return false
  130. }
  131. }
  132. // 设置表单背景
  133. function setBgColor(ele, form) {
  134. form.firstElementChild.style.backgroundColor = ele.value
  135. }
  136. // 文件上传
  137. function fileUploads(form) {
  138. let tips = ''
  139. if (form.user_pic.value.length === 0) {
  140. tips += '文件不能为空'
  141. } else {
  142. tips += '上传成功'
  143. }
  144. alert(tips)
  145. }
  146. </script>
  147. </body>
  148. </html>

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议