Categories:

JavaScript Kit > JavaScript Reference > Here

Text Object

Last updated: June 20th, 2004

Text fields (<input type="text">) within your form can be accessed and manipulated using JavaScript, via the corresponding Text object. To access a text field in JavaScript, use the syntax:

document.myform.mytextfield //where mytextfield is the name of the field
document.myform.elements[i] //where i is the position of the text field within form

Escape sequences

For a list of Escape Sequences in JavaScript, such as newline, see here.

Events

Events Description
onBlur Code is executed when the focus is removed from the text field.
onChange Code is executed when the user changes the value within the text field, and removes focus away from the field.
onFocus Code is executed when the focus is set on the text field.
onKeyDown Code is executed when user presses down the key within the text field.
onKeyPress Code is executed when user presses the key within the text field.
onKeyUp Code is executed when user releases a key within the text field.
onSelect Code is executed when user selects some text within the text field.

Properties

Properties Description
accessKey String value that sets/ returns the accessKey for the field.
disabled Boolean value that sets/ returns whether the field is disabled.
form References the form that contains the text field.
name Reflects the name of the text field (the name attribute).
type A property available on all form elements, "type" returns the type of the calling form element, in this case, "text".
value Read/write string that specifies the value of the text field.

Methods

Methods Description
blur() Removes focus away from the text field.
focus() Sets focus on the text field.
select() Highlights the content of the text field.

Reference List

Partners
Right column

CopyRight 1998-2014 JavaScript Kit. NO PART may be reproduced without author's permission.