美文网首页
输入类型

输入类型

作者: Leathy | 来源:发表于2017-09-15 18:07 被阅读8次

输入类型:text

<input type="text"> 定义供文本输入的单行输入字段:

实例

<form>
First name:<br>
<input type="text" name="firstname">
<br>
Last name:<br>
<input type="text" name="lastname">
</form>

输入类型:password

<input type="password"> 定义密码字段:

<form>
User name:<br>
<input type="text" name="username">
<br>
User password:<br>
<input type="password" name="psw">
</form>

注释:password 字段中的字符会被做掩码处理(显示为星号或实心圆)。

输入类型:submit

<input type="submit"> 定义提交表单数据至表单处理程序的按钮。
表单处理程序(form-handler)通常是包含处理输入数据的脚本的服务器页面。
在表单的 action 属性中规定表单处理程序(form-handler):
实例:

<form action="action_page.php">
First name:<br>
<input type="text" name="firstname" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="submit" value="Submit">
</form> 

Input Type: radio

<input type="radio"> 定义单选按钮。
Radio buttons let a user select ONLY ONE of a limited number of choices:(只能选一个)

<form>
<input type="radio" name="sex" value="male" checked>Male
<br>
<input type="radio" name="sex" value="female">Female
</form>

Input Type: checkbox<input type="checkbox"> 定义复选框。

复选框允许用户在有限数量的选项中选择零个或多个选项。

<form>
<input type="checkbox" name="vehicle" value="Bike">I have a bike<br>
<input type="checkbox" name="vehicle" value="Car">I have
 a Car<br>
</form>

输入类型:按钮

<input type="button> 定义按钮。

<input type="button" onclick="alert('Hello World')" value="Click Me!">

输入类型: 数字

<input type="number"> 用于应该包含数字值的输入字段。
您能够对数字做出限制。
根据浏览器支持,限制可应用到输入字段。

<form>
  Quantity (between 1 and 5):
 <input type="number" name="quantity" min="1" max="5">
</form>
screenshot.png

输入类型:date
<input type="date"> 用于应该包含日期的输入字段。
根据浏览器支持,日期选择器会出现输入字段中。

<form>
  Birthday:
  <input type="date" name="bday">
</form>
<form>
  Enter a date before 1980-01-01:
  <input type="date" name="bday" max="1979-12-31"><br>
  Enter a date after 2000-01-01:
  <input type="date" name="bday" min="2000-01-02"><br>
</form>

输入类型:color
<input type="color"> 用于应该包含颜色的输入字段。
根据浏览器支持,颜色选择器会出现输入字段中。
实例

<form>
  Select your favorite color:
  <input type="color" name="favcolor">
</form>

输入类型:range

<input type="range">用于应该包含一定范围内的值的输入字段。
根据浏览器支持,输入字段能够显示为滑块控件。
实例

<form> <input type="range" name="points" min="0" max="10"></form>

您能够使用如下属性来规定限制:min、max、step、value。

输入类型:month

<input type="month"> 允许用户选择月份和年份。
根据浏览器支持,日期选择器会出现输入字段中。
实例

<form>
  Birthday (month and year):
  <input type="month" name="bdaymonth">
</form>

输入类型:week

<input type="week"> 允许用户选择周和年。
根据浏览器支持,日期选择器会出现输入字段中。

<form>
  Select a week:
  <input type="week" name="week_year">
</form>

输入类型:time

<input type="time"> 允许用户选择时间(无时区)。
根据浏览器支持,时间选择器会出现输入字段中。
实例

<form>
  Select a time:
  <input type="time" name="usr_time">
</form>

输入类型:datetime

<input type="datetime"> 允许用户选择日期和时间(有时区)。
根据浏览器支持,日期选择器会出现输入字段中。

<form>
  Birthday (date and time):
  <input type="datetime" name="bdaytime">
</form>

后面略

相关文章

网友评论

      本文标题:输入类型

      本文链接:https://www.haomeiwen.com/subject/qvcesxtx.html