Table of Contents
email type
url type
number type
range type
Date Pickers Date picker type
search type
color type
tel type
Home Web Front-end Front-end Q&A What are the new form element types in html5

What are the new form element types in html5

Dec 17, 2021 pm 03:11 PM
html5

The new form element types in html5 are: 1. email type; 2. url type; 3. number type; 4. range type; 5. date selector type (date, month, week, time etc.); 6. search type; 7. color type; 8. tel type.

What are the new form element types in html5

The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.

HTML forms are used to collect different types of user input. In HTML forms, the element is the most important form element. Elements have many forms. According to different type attributes, the type types in the original HTML form include text, password, radio, submit, etc. In the new HTML5, there are multiple new form input types. These new features provide better input control and validation.

This article will introduce the following new form element input types:

  • email
  • url
  • number
  • range
  • Date pickers (date, month, week, time, datetime, datetime-local)
  • search
  • color
  • tel

email type

When the type attribute is set to email, when submitting the form, it will automatically verify whether the value of the email field conforms to the standard format of email, and you no longer need to use regular expressions yourself. I went to verify the format of the email.

Example

Email:<input type="email" name="useremail" />
Copy after login

url type

When the type attribute is set to url, when the form is submitted, it will automatically verify whether the value of the url field conforms to the standard format of the url.

Example

Linkpage:<input type="url" name="link_url" />
Copy after login

number type

When the type attribute is set to number, it will automatically check whether the input content is of numeric type. You can also set the input box number restrictions.

Example

Number:<input type="number" name="user_num" min="1" max="10" />
Copy after login

For numerically qualified attributes:

AttributeDescription
maxSpecifies the maximum value allowed
minSpecifies the minimum value allowed
stepSpecifies the legal number interval (if step="3", the legal number is -3,0,3,6, etc.)
valueSpecifies the default value
disabledSpecifies that the input field is disabled
maxlengthSpecifies the maximum character length of the input field
patternSpecifies the pattern used to validate the input field
readonlySpecifies that the value of the input field cannot be modified
requiredSpecifies that the value of the input field is required
sizeSpecifies the visible characters of the input field

range type

range type is used for An input field that should contain numeric values ​​within a range. Range types are displayed as sliders. You can also set limits on the numbers that are accepted.

Example

<input type="range" name="user_range" min="1" max="10" />
Copy after login

The attributes used for number qualification are the same as the first four of the number type.

Date Pickers Date picker type

is used to select dates and times.

Example

Date:<input type="date" name="user_date" />
Copy after login

Input type for selecting date and time:

  • date selects day, month, year
  • month selects month, Year
  • week Select week and year
  • time Select time (hours and minutes)
  • datetime Select time, day, month, year (UTC time, time zone)
  • datetime-local Select time, day, month, year (local time)

search type

is used for search fields, such as site search or Google search (search field behaves like a regular text field).

Example

Search Google:<input type="search" name="googlesearch">
Copy after login

color type

When the type attribute is set to color, it will automatically check whether the input content is in color format.

Example

Select your favorite color:<input type="color" name="favcolor">
Copy after login

tel type

When the type attribute is set to tel, it will automatically check whether the input content is in the phone number format.

Example

Telephone:<input type="tel" name="usrtel">
Copy after login

Related recommendations: "html video tutorial"

The above is the detailed content of What are the new form element types in html5. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles