Blogger Information
Blog 6
fans 0
comment 0
visits 8305
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
一次搞定注册表单常用元素与属性【附会员注册html实例】
导导的PHP学习笔记
Original
4221 people have browsed it

表单在网站中是经常用到的,特别是在用户注册方面,是必不可少的,我把表单元素及其常用的属性都用一个会员注册的表单写在一起了,具体如下所示

展示效果(样式省略未写):

代码部分:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>会员注册页面</title>
  7. </head>
  8. <body>
  9. <div
  10. class="container"
  11. style="width: 400px; height: auto; margin: 50px auto"
  12. >
  13. <h3>会员注册</h3>
  14. <form action="check.php" method="POST" enctype="multipart/form-data">
  15. <label for="username">用户名:</label>
  16. <input
  17. type="text"
  18. id="username"
  19. name="username"
  20. value=""
  21. placeholder="至少6位"
  22. autofocus
  23. required
  24. /><br />
  25. <label for="">性别:</label>
  26. <input type="radio" id="male" name="gender" value="male" /><label
  27. for="male"
  28. ></label
  29. >
  30. <input type="radio" id="female" name="gender" value="female" /><label
  31. for="female"
  32. ></label
  33. >
  34. <input
  35. type="radio"
  36. id="secret"
  37. name="gender"
  38. value="secret"
  39. checked
  40. /><label for="secret">保密</label><br />
  41. <label for="email">邮箱地址:</label>
  42. <input
  43. type="email"
  44. id="email"
  45. name="email"
  46. value=""
  47. placeholder="123456@qq.com"
  48. required
  49. /><br />
  50. <label for="user_url">你的网站:</label>
  51. <input
  52. type="url"
  53. id="user_url"
  54. name="user_url"
  55. value=""
  56. placeholder="https://www.baidu.com"
  57. />
  58. <br />
  59. <label for="hobby">你的爱好</label>
  60. <input type="checkbox" id="movie" name="hobby[]" value="movie" /><label
  61. for="movie"
  62. >看电影</label
  63. >
  64. <input
  65. type="checkbox"
  66. id="coding"
  67. name="hobby[]"
  68. value="coding"
  69. /><label for="coding">敲代码</label>
  70. <input type="checkbox" id="travel" name="hobby[]" value="travel" /><label
  71. for=travel""
  72. >旅游</label
  73. >
  74. <input type="checkbox" id="shoot" name="hobby[]" value="shoot" /><label
  75. for="shoot"
  76. >旅游</label
  77. >
  78. <br />
  79. <label for="lovecolor">喜欢的颜色:</label>
  80. <input type="color" id="lovecolor" name="lovecolor" value="" required />
  81. <br />
  82. <label for="bday">你的生日:</label>
  83. <input type="date" id="bday" name="bday" value="" required />
  84. <br />
  85. <label for="usrtel">你的电话:</label>
  86. <input type="tel" id="usrtel" name="usrtel" value="" required />
  87. <br />
  88. <label for="edu">你的学历:</label>
  89. <select name="edu" id="edu">
  90. <option value="1">高中</option>
  91. <option value="2">大专</option>
  92. <option value="3" selected>本科</option>
  93. <option value="4">研究生</option>
  94. <option value="5">家里蹲</option>
  95. </select>
  96. <br />
  97. <label for="usrpic">你的头像:</label>
  98. <input type="hidden" name="MAX_FILE_SIZE" value="1024">
  99. <input type="file" id="usrpic" name="usrpic" required />
  100. <br />
  101. <label for="resume">你的简历:</label>
  102. <input type="hidden" name="MAX_FILE_SIZE" value="10240">
  103. <input type="file" id="resume" name="resume" required />
  104. <br />
  105. <label for="usersign">个性签名:</label>
  106. <textarea name="usersign" id="usersign" cols="30" rows="10" placeholder="不要超过50个字!"></textarea>
  107. <br />
  108. <label for="pwd1">密码:</label>
  109. <input
  110. type="password"
  111. id="pwd1"
  112. name="pwd1"
  113. value=""
  114. placeholder="至少6位,由数字和字母构成"
  115. required
  116. /><br />
  117. <label for="pwd2">密码确认:</label>
  118. <input
  119. type="password"
  120. id="pwd2"
  121. name="pwd2"
  122. value=""
  123. placeholder="********"
  124. required
  125. /><br />
  126. <button type="reset">重置</button>
  127. <button>提交</button>
  128. </form>
  129. </div>
  130. </body>
  131. </html>
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:没有任何一个表单会将全部控件用上的, 每个控件都有自己的应用场景
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post