Input Text name property
Example
Get the name of the text field:
var x = document.getElementById("myText").name;
x The output is:
fname
Try it »
Definition and Usage
The name property sets or returns the name of the text field.
The name property is used to identify the form data submitted to the server, or to reference the form data on the client side through JavaScript.
Note: Only form elements with the name property set can pass their values when the form is submitted.
Browser support

All major browsers support the name property.
Syntax
Return the name attribute:
textObject
.name
Set the name attribute:
textObject
.name=
name
Attribute values
| Value | Description |
|---|---|
| name | Specifies the name of the text field |
Technical details
| Return Value: | String, representing the name of the text field |
|---|
More examples
Example
Modify the name of the text field:
document.getElementById("myText").name = "username";
Try it »
Related pages
HTML Reference Manual: HTML name attribute
The Input Text object