Home > Web Front-end > H5 Tutorial > body text

Form attributes in HTML5

黄舟
Release: 2016-12-22 15:14:40
Original
1402 people have browsed it

This chapter introduces the new form attributes of HTML 5.

New form attributes: autocomplete, novalidate.

New input attributes: autocomplete, autofocus, form, form overrides (formaction, formenctype, formmethod, formnovalidate, formtarget), height and width, list, min, max and step, multiple, pattern (regexp), placeholder, required.

Browser supports

Form attributes in HTML5

autocomplete attribute

autocomplete attribute stipulates that the form or input field should have auto-complete function.

Example:

<!DOCTYPE HTML>
<html>
<body>
<form action="demo_form.php" method="get" autocomplete="on">
  First name:
  <input type="text" name="fname" />
  <br />
  Last name:
  <input type="text" name="lname" />
  <br />
  E-mail:
  <input type="email" name="email" autocomplete="off" />
  <br />
  <input type="submit" />
</form>
<p>请填写并提交此表单,然后重载页面,来查看自动完成功能是如何工作的。</p>
<p>请注意,表单的自动完成功能是打开的,而e-mail 域是关闭的。</p>
</body>
</html>
Copy after login

Note: In some browsers, you may need to enable autocomplete for this attribute to take effect.


autofocus attribute

The autofocus attribute specifies that when the page loads, the field automatically gains focus.

Note: The autofocus attribute applies to all tag types.

For example:

<!DOCTYPE HTML>
<html>
<body>
<form action="demo_form.php" method="get">  User name:
  <input type="text" name="user_name" autofocus />
  <input type="submit" />
</form>
</body>
</html>
Copy after login

form attribute

The form attribute specifies one or more forms to which the input field belongs.

Note: The form attribute applies to all tag types.

The form attribute must reference the id of the form it belongs to. For example:

<!DOCTYPE HTML>
<html>
<body>
<form action="demo_form.php" method="get" id="user_form">
  First name:
  <input type="text" name="fname" />
  <input type="submit" />
</form>
<p>下面的输入域在form 元素之外,但仍然是表单的一部分。</p>
Last name:
<input type="text" name="lname" form="user_form" />
</body>
</html>
Copy after login

The above is the content of the form attributes in HTML5. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!