首頁  >  文章  >  web前端  >  HTML 表單輸入類型

HTML 表單輸入類型

WBOY
WBOY原創
2024-09-04 16:53:54450瀏覽

; HTML中的標籤用於設計Web表單中的交互控件,以接受來自用戶端的資料。根據所使用的用戶代理和設備,可以使用多種類型的控制小部件和輸入資料。 標籤是所有 HTML 中使用的最重要的元素之一,因為它具有大量的屬性和輸入類型組合。在本主題中,我們將學習 HTML 表單輸入類型。

HTML 表單輸入類型

標籤是 HTML

的重要元素。元素。 中的「type」屬性標籤可以有多種類型,用於定義資訊字段,例如提供一個文字方塊。 的預設類型是標籤是文字。

HTML 中可用的「輸入」類型清單

Type Description Format Example
button Used to define a push button with the text of the button being the value of the value attribute. HTML 表單輸入類型


checkbox Used to define a checkbox allowing users to select/deselect its values. HTML 表單輸入類型


Cricket
Tennis
Football
file Used to define a file upload feature on the local system with the accept attribute being used to restrict the file types for upload. HTML 表單輸入類型


<input type="file" name="newfile">

hidden Used to hide a control whose value will be submitted on the server. There is an example in the next column, but it’s hidden!
image A graphical submit button — displaying an image defined with the src attribute. The alt attribute displays if the image src is missing. HTML 表單輸入類型


password Used to define a single-line text field whose value is obscured, and it will also alert the user if the site is not secure HTML 表單輸入類型



radio Used to define a radio button and select a single value out of multiple. HTML 表單輸入類型


Red
Blue
Green
reset Used to define a button to reset the form values to its defaults. HTML 表單輸入類型


submit Used to define a submit button for the form. HTML 表單輸入類型


text Used to define a text field in the form. HTML 表單輸入類型



List of the types of “input” available in HTML5

Type Description Format Example
color Used to define the color of the elements in an HTML form. It takes a hexadecimal input. HTML 表單輸入類型


datetime-local Used to define an element for date and time in the HTML form with opening a date picker or numeric wheels for the month, day, and year, when used in supported browsers. HTML 表單輸入類型


email Used to define a text field for email which has all the predefined validations done for checking an email. HTML 表單輸入類型


date Used to define a date picker for the HTML form. HTML 表單輸入類型


number Used to input numbers in the HTML form by displaying a spinner and adding default validation when used in supported browsers. HTML 表單輸入類型


range Used to define a range in the HTML form. HTML 表單輸入類型


search Used to define single-line text fields for entering search strings. HTML 表單輸入類型


tel Used to define a telephone entering field within an HTML form. HTML 表單輸入類型


time Used to define a field for entering time in HTML form HTML 表單輸入類型


url Used to define a text field for entering a url in the HTML form with all its validations being performed automatically.

 

HTML 表單輸入類型


week Used to define a text field for entering the week-year number and a week number with no time zone. HTML 表單輸入類型


datetime Used to define a text field for entering a date and time (hour, minute, second, and fraction of a second) based on the UTC time zone. HTML 表單輸入類型


屬性

以下部分提供了一個表格,列出了所有相關屬性以及簡要說明。該表後面是更詳細地描述每個屬性的列表,以及與它們關聯的輸入類型。下面更詳細地定義了大多數或所有輸入類型所共有的那些。

Attribute Types
1.       accept file
2.       alt image
3.       autocomplete all
4.       autofocus all
5.       capture file
6.       checked radio, checkbox
7.       dirname text, search
8.       disabled all
9.       form all
10.    formaction image, submit
11.    formenctype image, submit
12.    formmethod image, submit
13.    formnovalidate image, submit
14.    formtarget image, submit
15.    height image
16.    list almost all
17.    max numeric types
18.    maxlength password, search, tel, text, url
19.    min numeric types
20.    minlength password, search, tel, text, url
21.    multiple email, file
22.    name all
23.    pattern password, text, tel
24.    placeholder password, search, tel, text, url
25.    readonly almost all
26.    required almost all
27.    size email, password, tel, text
28.    src image
29.    step numeric types
30.    type all
31.    value all
32.    width image

結論 – HTML 表單輸入類型

借助 HTML5 新的表單輸入類型,我們可以增強用戶體驗,打造面向未來的應用程序,並使開發人員的編碼變得更加容易。對這些新表單輸入類型的支援非常強大,尤其是在具有鍵盤的行動裝置中。這些輸入類型對於可用性而言是安全的,並且還為使用者提供了額外的實用程式。

以上是HTML 表單輸入類型的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn