Blogger Information
Blog 5
fans 2
comment 0
visits 3222
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
表单元素_9月30日作业01
边边
Original
525 people have browsed it

表单元素

一、表单元素标签

标签 作用 学习的属性
form 包裹其他表单元素 action,method,enctype
input 文本密码单选多选文件上传框 type,name,value,placeholderautofocus,reqiured
select,option 下拉框 selected
textarea 文本域 多行文本框

二、form标签的属性

  • action属性的值表示表单数据回传位置
  • method属性的值表示表单数据以何种方式回传
  • enctype属性的值表示文件上传模式

三、input标签的属性

input标签常见有以下属性:

  • type属性的值代表不同的input表单类型
    • text:文本框
    • email:邮件地址框
    • password:密码框
    • radio:单选框
    • checkbox:多选框
    • file:文件选择上传框
    • hidden:隐藏
  • placeholder属性的值代表表单中的提示文字
  • reqiuered属性表示本表单为必填项
  • autofocus属性表示本表单自动获得焦点

四、注册界面案例

  1. <!DOCTYPE html>
  2. <html lang="zh-cn">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <link rel="stylesheet" href="static/css/1.css" />
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. <h3 class="title">用户注册</h3>
  11. <form
  12. action="check.php"
  13. method="post"
  14. class="register"
  15. enctype="multipart/form-data"
  16. >
  17. <label for="username">账号:</label>
  18. <input
  19. type="text"
  20. name="username"
  21. id="username"
  22. value=""
  23. placeholder="最少6位"
  24. required
  25. autofocus
  26. />
  27. <label for="email">邮箱:</label>
  28. <input
  29. type="email"
  30. name="email"
  31. id="email"
  32. value=""
  33. placeholder="输入有效邮件地址"
  34. reqiured
  35. />
  36. <label for="pwd1">密码:</label>
  37. <input
  38. type="password"
  39. name="pwd1"
  40. id="pwd1"
  41. value=""
  42. placeholder="输入6位密码"
  43. reqiured
  44. />
  45. <label for="secret">性别:</label>
  46. <div class="gender">
  47. <div>
  48. <input type="radio" name="gender" id="male" value="male" />
  49. <label for="male"></label>
  50. </div>
  51. <div>
  52. <input type="radio" name="gender" id="female" value="female" />
  53. <label for="female"></label>
  54. </div>
  55. <div>
  56. <input
  57. type="radio"
  58. name="gender"
  59. id="secret"
  60. value="secret"
  61. checked
  62. /><label for="secret">保密</label>
  63. </div>
  64. </div>
  65. <label for="game">兴趣:</label>
  66. <div class="hobby">
  67. <div>
  68. <input
  69. type="checkbox"
  70. name="hobby[]"
  71. id="game"
  72. value="game"
  73. checked
  74. /><label for="game">游戏</label>
  75. </div>
  76. <div>
  77. <input
  78. type="checkbox"
  79. name="hobby[]"
  80. id="shoot"
  81. value="shoot"
  82. /><label for="shoot">摄影</label>
  83. </div>
  84. <div>
  85. <input
  86. type="checkbox"
  87. name="hobby[]"
  88. id="travel"
  89. value="travel"
  90. /><label for="travel">旅游</label>
  91. </div>
  92. <div>
  93. <input
  94. type="checkbox"
  95. name="hobby[]"
  96. id="program"
  97. value="program"
  98. /><label for="program">编程</label>
  99. </div>
  100. </div>
  101. <label for="edu">学历:</label>
  102. <select name="edu" id="edu">
  103. <option value="1">专科</option>
  104. <option value="2">本科</option>
  105. <option value="3" selected>硕士</option>
  106. </select>
  107. <label for="user_pic">头像:</label>
  108. <div>
  109. <input type="hidden" name="file_size" value="80000" />
  110. <input type="file" name="user_pic" id="user_pic" />
  111. <div class="user_pic"></div>
  112. </div>
  113. <label for="user_resume">简历:</label>
  114. <div>
  115. <input type="hidden" name="text_size" value="80000" />
  116. <input type="file" name="user_resume" id="user_resume" />
  117. <div class="user_resume"></div>
  118. </div>
  119. <label for="beizhu">备注:</label>
  120. <textarea
  121. name="beizhu"
  122. id="beizhu"
  123. cols="30"
  124. rows="10"
  125. placeholder="最多输入300字"
  126. ></textarea>
  127. <span>还能输入10字</span>
  128. <button>提交</button>
  129. </form>
  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