search
HomeWeb Front-endFront-end Q&ANew attributes of HTML5 form

New attributes of HTML5 form

Jun 11, 2018 pm 10:32 PM

1.HTML 5 formaction attribute

Definition and usage

The formaction attribute specifies where to go when submitting a form. Send form data.

Note:

1. The formaction attribute specifies the URL of the file that handles the input control when the form is submitted.

2. The formaction attribute overrides the action attribute of the

element.

Note: The formaction attribute applies to type="submit" and type="image".

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>formaction</title>
</head>
<body>
<form id="testform">
    <input type="submit" name="s1" value="v1" formaction="http://localhost:8080/index01/Test01.jsp">提交到http://localhost:8080/index01/Test01.jsp
    <input type="submit" name="s2" value="v2" formaction="http://localhost:8080/index01/Test02.jsp">提交到http://localhost:8080/index01/Test02.jsp
    <input type="submit" name="s3" value="v3" formaction="http://localhost:8080/index01/Test03.jsp">提交到http://localhost:8080/index01/Test03.jsp
</form>
</body>
</html>

2.HTML 5

定义和用法

formmethod 属性覆盖 form 元素的 method 属性。

可以通过以下方式发送 form-data :

  • 以 URL 变量 (使用 method="get") 的形式来发送

  • 以 HTTP post (使用 method="post") 的形式来发送

该属性与 type="submit" 配合使用。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <form id="testform">
        <input type="submit" name="s1" value="v1" formmethod="post" formaction="http://localhost:8080/index01/Test01.jsp">http://localhost:8080/index01/Test01.jsp
        <input type="submit" name="s2" value="v2" formmethod="get" formaction="http://localhost:8080/index01/Test02.jsp">http://localhost:8080/index01/Test02.jsp
        <input type="submit" name="s1" value="v1" formmethod="post" formaction="http://localhost:8080/index01/Test03.jsp">http://localhost:8080/index01/Test03.jsp
    </form>
</body>
</html>

<!DOCTYPE HTML>
<html>
<body>
<form action="/example/html5/demo_form.asp" method="get">
  姓:<input type="text" name="lname" /><br />
  名:<input type="text" name="fname" /><br />
<button type="submit" >提交</button>
<button type="submit" formmethod="post" formaction="/example/html5/demo_post.asp">使用 POST 来提交</button>
</form>
</body>
</html>

3HTML 5 autofocus 属性

定义和用法

autofocus 属性规定当页面加载时 input 元素应该自动获得焦点。

如果使用该属性,则 input 元素会获得焦点。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form>
    <input type="text">
    <input type="text" autofocus>
</form>
</body>
</html>

本文讲解了HTML5 form新增的属性 ,更多相关内勤请关注php中文网。

相关推荐:

JQuery中DOM操作——wrap

django 使用 request 获取浏览器发送的参数

React this绑定的几点思考

The above is the detailed content of New attributes of HTML5 form. 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
How to change the background color of a navbar in BootstrapHow to change the background color of a navbar in BootstrapAug 26, 2025 am 05:19 AM

UseBootstrap’sbuilt-inbackgroundcolorclasseslikebg-primary,bg-success,orbg-darkandpairwithnavbar-darkornavbar-lightforpropertextcontrast.2.Applycustomcolorsbyaddingacustomclasstothenavbaranddefiningthebackground-colorinCSSusinghex,RGB,orRGBAvaluesfor

What are physical and logical tags in HTML?What are physical and logical tags in HTML?Aug 26, 2025 am 05:10 AM

Physical tags are used to define the appearance of text, and logical tags are used to define the meaning of text; 1. Physical tags such as , directly control styles, but modern development recommends using CSS instead; 2. Logical tags such as , give content semantics, improve accessibility and SEO, and should be used first; 3. Modern HTML advocates the separation of structure and styles, emphasizing the combination of semantic tags and CSS to achieve a more maintainable, responsive and barrier-free web page.

How to use the meter tag in HTMLHow to use the meter tag in HTMLAug 26, 2025 am 03:44 AM

Thetagisusedtodisplayascalarmeasurementwithinaknownrange,suchasaquizscoreordiskusage,andrendersasahorizontalgauge;2.Keyattributesincludevalue(required),min,max,low,high,optimum,andtitleforaccessibility;3.Visualrangesaredefinedbylow,high,andoptimumtoi

How to animate a button with CSSHow to animate a button with CSSAug 26, 2025 am 02:17 AM

UseCSStransitionsforsmoothhovereffectsbyapplyingtransitionpropertiestobackground-color,transform,andbox-shadowtocreatesubtleanimations.2.Addscaleorcolortransformationswithtransform:scale()andcolorchangestoenhanceinteractivitywhilekeepingchangesminima

How to use article and section tags in HTMLHow to use article and section tags in HTMLAug 26, 2025 am 01:23 AM

Use tags for independent, self-containable content, such as blog posts, news stories, product lists or user comments, which can exist independently even if they are out of context; use tags for grouping related content with the same topic, usually containing a title, such as the "Services" or "Latest Articles" block in the page; 1. Emphasize the independence of the content, which can be aggregated or shared; 2. Emphasize the logical grouping of the content, which should have clear themes and titles; 3. Both can be used in nested, such as one containing multiples, or one divided into multiples; 4. Avoid using only for style, without topics or titles; 5. Correct use of these semantic tags can improve accessibility, SEO and code readability, making the web page structure clearer and easier to understand.

How to create a responsive services section with CSSHow to create a responsive services section with CSSAug 26, 2025 am 01:10 AM

StartwithsemanticHTMLusingasectioncontainerandservicecardsforclarity.2.UseCSSFlexboxorGridtocreateaflexiblelayout,withFlexboxforsimplerlayoutsandGridformorecontrol.3.Applyresponsivedesignviamediaqueries:stackcardsonsmallscreens,displaytwoperrowontabl

How to use conditional comments in HTMLHow to use conditional comments in HTMLAug 25, 2025 pm 01:43 PM

ConditionalcommentsweresupportedonlyinInternetExplorer5through9andarenotavailableinmodernbrowsersorstandards.1.TheyalloweddeveloperstotargetspecificIEversionsusingspecialHTML-likesyntaxrecognizedonlybyIE.2.Commonconditionsincluded"IE","

How to use the source element in HTMLHow to use the source element in HTMLAug 25, 2025 pm 12:03 PM

Using elements can provide multiple media formats in or in tags. The browser selects the first supported format in order and uses type attributes to avoid downloading unsupported files; 2. Using elements in the elements can load different images according to the screen size or resolution, match the conditions through the media attribute and serve as the final fallback; 3. Always add type attributes, sort source files by priority, optimize performance in responsive design, and tests across browsers to ensure compatibility, do not render content itself, and only provide optional resources for the parent element.

See all articles

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

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.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Hot Topics