Easy Tutorial
❮ Prop Img Height Prop Week Required ❯

Input Text Object

Input Text Object

Example

Get the name of the text field:

var x = document.getElementById("myText").name;

x output result:

fname

Definition and Usage

The name attribute sets or returns the name of the text field.

The name attribute is used to identify form data after it has been submitted to the server, or to reference form data in client-side JavaScript.

Note: Only form elements with a name attribute will have their values passed when submitting a form.


Browser Support

All major browsers support the name attribute.


Syntax

Return the name attribute:

Set the name attribute:

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

Change the name of the text field:

document.getElementById("myText").name = "username";

Related Pages

HTML Reference: HTML <input> name Attribute


❮ Prop Img Height Prop Week Required ❯