How to specify the name of an input element?
Last Updated :
30 Dec, 2020
In this article, we will specify the name of an input element using HTML. To add the name of an input element, we use HTML <input> name attribute. The HTML <input> name attribute is used to specify a name for an <input> element. It is used to reference the form-data after submitting the form or to reference the element in JavaScript.
Syntax:
<input name="name">
Attribute Values: It contains a single value name that describes the name of the <input> element.
Example-1:
HTML
<!DOCTYPE html>
< html lang = "en" >
< head >
< title >
How to specify the name of an
input element using HTML?
</ title >
</ head >
< body style = "text-align: center;" >
< h1 style = "color: green;" >
GeeksforGeeks
</ h1 >
< h3 >
How to specify the name of an
input element using HTML?
</ h3 >
< form id = "myGeeks" >
< label for = "GFG" >Username</ label >
< input type = "text" id = "GFG" name = "GFG" >
< br >< br >
< label for = "GFG1" >Password</ label >
< input type = "password" id = "GFG1" name = "GFG1" >
< br >< br >
< input type = "submit" name = "submit" >
</ form >
</ body >
</ html >
|
Output:
Example-2:
HTML
<!DOCTYPE html>
< html >
< head >
< title >
HTML Input name Attribute
</ title >
</ head >
< body style = "text-align:center;" >
< h1 >GeeksForGeeks</ h1 >
< h2 >HTML Input name Attribute</ h2 >
< form id = "myGeeks" >
< input type = "text"
id = "text_id"
name = "geeks"
pattern = "[A-Za-z]{3}"
value = "Manas Chhabra" >
</ form >
< br >
</ body >
</ html >
|
Output:
Share your thoughts in the comments
Please Login to comment...