Input Text nameProperty

Input Text 对象参考手册Input Text Object

Example

Get the name of the text field:

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

xThe output result is:

fname

Try it Yourself »


Definition and Usage

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

The name property is used to identify form data after it is submitted to the server, or to reference form data on the client side via JavaScript.

Note:Only form elements that have a name attribute set can pass their values when submitting the form.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

All major browsers support the name property.


Syntax

Return the name property:

textObject.name

Set the name property:

textObject.name=name

Property Values

Value Description
name Specifies the name of the text field

Technical Details

Return Value: A string, representing the name of the text field


More Examples

Example

Change the name of the text field:

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

Try it Yourself »

Related Pages

HTML Reference Manual:HTML <input> name Attribute


Input Text 对象参考手册Input Text Object Other Extensions