Textbox

A text input field in which the user can enter text. It is similar to the HTML input element. Only one line of text is displayed by default. The multiline attribute can be specified to display a field with multiple rows.

More information about textbox

Example:

    <label control="your-name" value="Enter your name:"/>
    <textbox id="your-name"/>

The textbox element implements the following interfaces:

nsIAccessibleProvider   nsIDOMXULTextboxElement  

Attributes:

cols disabled maxlength multiline onchange
oninput preference readonly rows size
tabindex timeout type value wrap

Style Classes:

plain

Properties and Methods:

accessible disabled inputField maxLength readonly
select selectionEnd selectionStart setSelectionRange size
tabIndex textLength timeout type value

Attributes:

Inherited from XUL Element:

align
allowevents
allownegativeassertions
class
coalesceduplicatearcs
collapsed
container
containment
context
contextmenu
datasources
dir
empty
equalsize
flags
flex
height
hidden
id
insertafter
insertbefore
left
maxheight
maxwidth
menu
minheight
minwidth
mousethrough
observes
ordinal
orient
pack
persist
popup
position
preference-editable
ref
removeelement
sortDirection
sortResource
sortResource2
statustext
style
template
tooltip
tooltiptext
top
uri
wait-cursor
width

cols

Type: integer

The number of columns in the textarea.

disabled

Type: boolean

Indicates whether the textbox is disabled or not. If this attribute is set to true, the textbox is disabled. This is usually drawn with the text in grey. If the textbox is disabled, it does not respond to user actions. The element cannot be focused and the command event will not fire. The element will still respond to mouse events. To enable the textbox, leave the attribute out entirely as opposed to setting the value to false.

maxlength

Type: integer

The maximum number of characters that the textbox allows to be entered.

multiline

Type: boolean

If true, the textbox displays multiple lines. If the user presses ENTER, a new line is started. If false, the textbox only allows entry of one line.

onchange

Type: script code

This event is sent when the value of the textbox is changed. The event is not sent until the focus is moved to another element.

oninput

Type: script code

This event is sent when a user enters text in a textbox. This event is only called when the text displayed would change, thus it is not called when the user presses non-displayable keys.

preference    Mozilla 1.8

Type: element id

Connects the textbox to a corresponding preference. This attribute only has any effect when used inside a prefwindow. The value of the preference will be updated to match the value property of the textbox.

readonly

Type: boolean

If set to true, then the user cannot modify the value of the textbox. However, the value may still be modified by a script.

rows

Type: integer

The number of rows in the textarea.

size

Type: integer

The number of characters that can be displayed in the textbox.

tabindex

Type: integer

The tab order of the element. The tab order is the order in which the focus is moved when the user presses the Tab key. Elements with a higher tabindex are later in the tab order sequence.

timeout

Type: integer

For timed textboxes, the number of milliseconds before the timer fires a command event. The timer starts after the user types a character. If the user types another character, the timer resets.

type

Type: one of the values below

You can set the type attribute to one of the values below for a more specialized type of textbox. Don't set the type if you wish to use a regular textbox.

value

Type: string

The default value entered in the textbox. The attribute only holds the default value and is never modified when the user enters text. To get the updated value, use the value property.

wrap

Type: string

Set this attribute to the value 'off' to disable word wrapping in the textbox. If this attribute is not specified, word wrapping is enabled.


Style Classes:

The following classes may be used to style the element. These classes should be used instead of changing the style of the element directly since they will fit more naturally with the user's selected theme.

plain

This class causes the textbox to be displayed with no border or margin. This is useful in combination with readonly textboxes to create labels where the text may still be selected.


Properties and Methods:

Inherited from XUL Element:

align
allowEvents
blur
boxObject
boxObject.element
boxObject.getLookAndFeelMetric
boxObject.height
boxObject.screenX
boxObject.screenY
boxObject.width
boxObject.x
boxObject.y
builder
className
click
collapsed
contextMenu
controllers
database
datasources
dir
doCommand
flex
focus
getElementsByAttribute
height
hidden
id
left
maxHeight
maxWidth
menu
minHeight
minWidth
observes
ordinal
orient
pack
persist
ref
resource
statusText
style
tooltip
tooltipText
top
width

Inherited from Element:

addEventListener
appendChild
attributes
childNodes
cloneNode
dispatchEvent
firstChild
getAttribute
getAttributeNS
getAttributeNode
getAttributeNodeNS
getElementsByTagName
getElementsByTagNameNS
hasAttribute
hasAttributeNS
hasAttributes
hasChildNodes
insertBefore
isSupported
lastChild
localName
namespaceURI
nextSibling
nodeName
nodeType
nodeValue
normalize
ownerDocument
parentNode
prefix
previousSibling
removeAttribute
removeAttributeNS
removeAttributeNode
removeChild
removeEventListener
replaceChild
setAttribute
setAttributeNS
setAttributeNode
setAttributeNodeNS
tagName

accessible

Type: nsIAccessible

Returns the accessibility object for the textbox.

disabled

Type: boolean

Gets and sets the value of the disabled attribute.

inputField

Type: textbox element

In Mozilla, the XUL textbox is implemented as a wrapper around an HTML input element. This read only property holds a reference to this inner input element.

maxLength

Type: integer

The maximum number of characters that the textbox allows to be entered.

readonly

Type: boolean

Gets and sets the value of the readonly attribute.

select ( )

Return Type: no return value

Select all the text in the textbox.

selectionEnd

Type: integer

Get or modify the end of the selected portion of the field's text. Use in conjuction with the selectionEnd property. The value specifies the index of the character after the selection. If this value is equal to the selectionStart property, no text is selected, but the value indicates the position of the caret (cursor) within the textbox.

selectionStart

Type: integer

Get or modify the beginning of the selected portion of the field's text. Use in conjuction with the selectionEnd property. The value specifies the index of the first selected character.

setSelectionRange ( start , end )

Return Type: no return value

Sets the selected portion of the textbox, where the start argument is the index of the first character to select and the end argument is the index of the character after the selection. Set both arguments to the same value to move the cursor to the corresponding position without selecting text.

size

Type: integer

Gets and sets the value of the size attribute.

tabIndex    Mozilla 1.8

Type: integer

Gets and sets the value of the tabindex attribute.

textLength

Type: integer

Holds the length of the text entered in the textbox. This property is read only.

timeout

Type: integer

Gets and sets the value of the timeout attribute.

type

Type: one of the values below

You can set the type attribute to one of the values below for a more specialized type of textbox. Don't set the type if you wish to use a regular textbox.

value

Type: string

Returns the text entered into the textbox. You can set this property to change the text in the textbox.


Copyright (C) 1999 - 2004 XulPlanet.com