Latest web development tutorials

HTML DOM Input Text name attribute

Input Text Object Reference Input Text Object

Examples

Get the name of the text field:

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

x The output is:

fname

try it"


Definition and Usage

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

name attribute is used to submit form data to a server after identification, or JavaScript form data referenced by the client.

Note: Only set the form element name attribute to pass their values when the form is submitted.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support name attribute.


grammar

Returns the name attribute:

textObject .name

Setting name attribute:

textObject .name = name

Property Values

value description
name It specifies the name of the text field

Technical details

return value: Name string representing the text field


More examples

Examples

Modify the name of the text field:

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

try it"

Related Pages

HTML Reference Manual: HTML <the INPUT> name attribute


Input Text Object Reference Input Text Object