表单的属性

accept-charset 规定在被提交表单中使用的字符集(默认:页面字符集)。
action 规定向何处提交表单的地址(URL)(提交页面)。
autocomplete 规定浏览器应该自动完成表单(默认:开启)。
enctype 规定被提交数据的编码(默认:url-encoded)。
method 规定在提交表单时所用的 HTTP 方法(默认:GET)。
name 规定识别表单的名称(对于 DOM 使用:document.forms.name)。
novalidate 规定浏览器不验证表单。
target 规定 action 属性中地址的目标(默认:_self)。
  1. <form action="/api/dataup" method="post">
  2. 名称: <input type="text" name="" id=""> <br />
  3. 邮箱: <input type="email" name="" id=""> <br />
  4. 密码: <input type="password" name="" id=""> <br />
  5. <button type="submit">提交</button>
  6. </form>

image.png

input_输入类型

属性名 输入框的类型 说明
type text
email
password
checkbox
radio
color
date
datetime-local
month
number
range
search
time
url
文本框
邮箱
密码
复选框
单选框
颜色选择器
日期
日期时间
年月
数字输入框
滑动条
搜索框
时间
URL
  1. <form action="/api/dataup" method="post">
  2. 名称: <input type="text" name="" id=""> <br />
  3. 邮箱: <input type="email" name="" id=""> <br />
  4. 密码: <input type="password" name="" id=""> <br />
  5. 复选框: <input type="checkbox" name="age" id="">
  6. <input type="checkbox" name="age" id=""> <br />
  7. 单选框: <input type="radio" name="sex" id="">
  8. <input type="radio" name="sex" id=""> <br />
  9. 颜色选择器: <input type="color" name="" id=""> <br />
  10. 日期输入框: <input type="date" name="" id=""> <br />
  11. 日期时间输入框<input type="datetime-local" name="" id=""> <br />
  12. 年月框: <input type="month" name="" id=""> <br />
  13. 数字输入框: <input type="number" name="" id=""> <br />
  14. 滑动条: <input type="range" name="" id=""> <br />
  15. 搜索框: <input type="search" name="" id=""> <br />
  16. 时间框: <input type="time" name="" id=""> <br />
  17. URL地址框: <input type="url" name="" id=""> <br />
  18. <input type="submit" />
  19. </form>

image.png

input_限制属性

属性 描述
disabled 规定输入字段应该被禁用。
max 规定输入字段的最大值。
maxlength 规定输入字段的最大字符数。
min 规定输入字段的最小值。
pattern 规定通过其检查输入值的正则表达式。
readonly 规定输入字段为只读(无法修改)。
required 规定输入字段是必需的(必需填写)。
size 规定输入字段的宽度(以字符计)。
step 规定输入字段的合法数字间隔。
value 规定输入字段的默认值。
  1. <input type="text" disabled="disabled" value="000">