JavaScript Reference :: Text

The easiest way to create a Text object is to get the HTML element using either the document method getElementById or getElementsByTagName to get a reference to an HTML input tag that has a type attribute of "text". Of course, you may also use document.createElement("input") and set the type to "text". Once you have the element, you can assign event handlers or modify the properties.

methods

void select(int beginningIndex, int endingIndex)
Selects the text in the control between the starting index and the ending index. If an ending index is not specified, the selection extends to the end of the text in the control.
object toSource()
Returns a literal representing the source code of the object e.g "function Object() { [native code] }" or "function Car(manufactuer, model, productionyear) { this.make = manufactuer; this.model = model; this.year = productionyear; }".
string toString()
Returns a string representing the object i.e. "[object Object]".
void unwatch(property)
Removes a previously set watchpoint.
								
object valueOf()
Returns the primitive value of the object e.g. "function Object() { [native code] }".
void watch(property, handlingFunction)
Calls the handlingFunction when the property is changed.
								

properties

constructor
The constructor method is the base method used to create an instance of the object.
defaultValue
The default value of the Password object.
form
A Form object representing the HTML form which contains the FileUpload object.
name
The value provided in the name attribute of the HTML tag.
prototype
Exposes the prototype for the method or property of the object.
type
The value provided in the type attribute of the HTML tag. This property is always "text".
value
The value of the element.

events

onblur
onchange
ondblclick
onfocus
onkeydown
onkeypress
onkeyup
onmousedown
onmouseout
onmouseover
onmouseup
onresize
onselect