The name attribute in the <form> tag is used to specify a name for the form element. It helps identify the form in JavaScript and during form handling.
- Assigns a unique name to the <form> element.
- Used to reference the form in JavaScript.
- Helps identify and manage forms easily.
Syntax:
<form name="formName">
<!-- form elements -->
</form>
Attribute Values: It contains a single value name which describes the name of the <form> element.
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
<body style="text-align:center;">
<h1 style="color:green;">
GeeksForGeeks
</h1>
<h2>HTML Form name Attribute.</h2>
<!--Driver Code Ends-->
<form id="users" action="#" name="Geeks">
First name:
<input type="text" name="fname" value="Manas">
<br> Last name:
<input type="text" name="lname" value="Chhabra">
<br>
<input type="submit" value="Submit">
</form>
<!--Driver Code Starts-->
</body>
</html>
<!--Driver Code Ends-->