HTML form name attribute
Examples
HTML form with name attribute:
<form
action="form_action.html"
method="get" name="myForm">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="button" onclick="formSubmit()" value="发送表单数据!">
</form>
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="button" onclick="formSubmit()" value="发送表单数据!">
</form>
try it"
Browser Support
All major browsers support name attribute.
Definition and Usage
name attribute specifies the name of the form.
name attribute is used to reference elements in JavaScript, or a reference to the form data when the form is submitted.
Differences between HTML 4.01 and HTML5
no.
Differences between HTML and XHTML
In XHTML, name attribute is obsolete. Please use the id attribute instead.
grammar
<form name="text">
Property Value
值 | 描述 |
---|---|
text | 规定表单的名称。 |
HTML <form> tag