Home>Article>Web Front-end> What are the new features of html5 forms?

What are the new features of html5 forms?

青灯夜游
青灯夜游 Original
2021-12-17 14:01:52 2897browse

The new features of html5 forms are: 1. New input type values (email, url, number, tel, color, date, etc.); 2. New form element attributes (placeholder, autofocus, form, min , max, pattern, etc.).

What are the new features of html5 forms?

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

H5’s new form features can be divided into two categories.

1. Type values of 10 inputs

1. email: email input field, provides simple email format verification when the form is submitted, and pops up a prompt window .

2. url: Address input field, which provides simple URL address format verification and pops up a prompt window when the form is submitted.

3. number: number input field. (min, max, step can be set)

4. tel: phone number input field, the number input field pops up in the mobile browser.

5. search: Search input field, a search button appears in the lower right corner of the mobile browser.

6. Range: range selection control.

7. color: color selection control.

8. date/month/week: time selection control.

2. 11 new attributes of form elements

1. autocomplete: automatic completion, whether to automatically record previously submitted data for the next input suggestion.

2. Placeholder: Placeholder, used to display prompt text in the input box. Unlike value, it cannot be submitted.

3. autofocus: automatically obtain input focus.

4. Multiple: Whether to allow multiple input values. If this attribute is declared, multiple values separated by commas are allowed to be entered in the input box.

5. form: The value is the id of a form. If set, the input field can be placed outside the form.

6. required: When the form is submitted, it will be verified whether there is input. If not, a prompt message will pop up.

7. maxlength: Limit the maximum length. It is only useful when there is input. It does not distinguish between Chinese and English.

7.5. minlength: limits the minimum length, but it is not an H5 standard attribute and is only supported by some browsers.

8. min: Limit the minimum value of the input number.

9. max: Limit the maximum value of the input number.

10. step: Limit the step size of the input number, used in conjunction with min.

11. pattern: Specify a regular expression to verify the input. (Regular defaults to add ^$ at the beginning and end)

Related recommendations: "html video tutorial"

The above is the detailed content of What are the new features of html5 forms?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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