Compartir a través de


INPUT TYPE=text XHTML Element

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

The INPUT TYPE=text element creates a single-line text entry control. This is an inline element and does not require a closing tag.

If INPUT is used without a TYPE attribute or with a nonvalid TYPE, it is recognized as INPUT TYPE=text by Internet Explorer Mobile.

Using this Element

There are some common properties and collections that apply to all the elements of the document object model, see Common Properties, Methods and Collections for the HTML Elements in Internet Explorer Mobile.

This element can be used within a web page with attributes.

This element can be used within scripts where it will have properties, events and methods.

Attributes

The following table shows items that Internet Explorer Mobile supports.

Attribute Value Description

ACCESSKEY

0…9, #, *

Gives access or focus to an active HTML element by using a keypad number.

> [!NOTE] > For Pocket PC for Windows Mobile 2003 Second Edition or later.

CLASS

 

Associates the element with a CSS style.

> [!NOTE] > Supported only for devices running Windows Mobile 2003 software or later.

DISABLED

 

Disables the button so that it appears dimmed and does not respond to user input.

> [!NOTE] > Supported only for devices running Windows Mobile 2003 software or later.

EMPTYOK

 

Boolean that indicates if leaving the contents of this control empty is acceptable.

FORMAT

A, a, N, n, X, x, M, m, *, 0...9

Specifies an input mask for the user input. This conforms to the WML 1.3 specification.

The format mask characters are:

A - Uppercase character

a - Lowercase character

N - Any number character

n - Any numeric, symbol or punctuation character

X - Combination of A and n

x - Combination of a and n

M - Any valid character, default is uppercase

m - Any valid character, default is lowercase

* - Preceeds any of the above formats. Indicates any number of characters of the specified format

0...9 - Proceeds any of the above formats. Indicates a fixed number of the specified format

Example:

<INPUT TYPE="text" NAME="test" FORMAT="NNN">

ID

 

Uniquely identifies the element within a document.

> [!NOTE] > Supported only for devices running Windows Mobile 2003 software or later

MAXLENGTH

0...#

Specifies the text entry control maximum length, in characters.

NAME

String

Specifies the button control name.

ONBLUR

 

Event that occurs when the text entry control loses focus by the pointing device or by tabbing navigation.

> [!NOTE] > Supported only for devices running Pocket PC 2002 and Smartphone 2002 software or later.

ONCHANGE

 

Event that occurs when the text entry control loses the input focus and its value has been modified since gaining focus.

> [!NOTE] > Supported only for devices running Pocket PC 2002 and Smartphone 2002 software or later.

ONFOCUS

 

Event that occurs when the text entry control receives focus by a pointing device or by tabbing navigation.

> [!NOTE] > Supported only for devices running Pocket PC 2002 and Smartphone 2002 software or later.

STYLE

 

Provides the definition of the CSS styles used for this element.

> [!NOTE] > Supported only for devices running Windows Mobile 2003 software or later.

TABINDEX

 

Sets the order in which elements are tabbed to.

> [!NOTE] > Supported only for devices running Windows Mobile 2003 software or later.

VALUE

String

Specifies the initial value for the text entry control. If the control has a name and a value (set by attribute, script or user input), on forms submission, the name or value pair is submitted to the server.

Scripting Properties

The following table shows items that Internet Explorer Mobile supports.

Property Type Access Comments

accessKey

string

Read/Write

Sets or retrieves the number associated with the accesskey attribute.

> [!NOTE] > Supported only for devices running Smartphone 2002 and Pocket PC 2002 software or later.

defaultValue

string

Read/Write

Retrieves the default value (initial contents) of the input type=text control.

disabled

boolean

Read/Write

Sets or retrieves the value that indicates whether the user can interact with the object.

> [!NOTE] > Supported only for devices running Smartphone 2002 and Pocket PC 2002 software or later.

form

object

Read

Retrieves a reference to the form that the object is embedded in.

> [!NOTE] > Supported only for devices running Smartphone 2002 and Pocket PC 2002 software or later.

maxLength

long

Read/Write

Sets or retrieves the maximum number of characters that the user can enter in a text control.

> [!NOTE] > Supported only for devices running Smartphone 2002 and Pocket PC 2002 software or later.

name

string

Read

Sets or retrieves the name of the input type=text control.

> [!NOTE] > Supported only for devices running Smartphone 2002 and Pocket PC 2002 software or later.

offsetHeight

Number

Read-only

Contains the height of the object in pixels, relative to the parent element.

offsetLeft

Number

Read-only

Contains the number of pixels from the left of the parent element.

offsetParent

String

Read-only

Contains a reference to the container object that defines the offsetTop and offsetLeft properties of the object.

offsetTop

Number

Read-only

Contains the number of pixels from the top of the parent element

offsetWidth

Number

Read-only

Contains the width of the object in pixels, relative to the parent element.

readOnly

boolean

Read/Write

 

size

long

Read

Sets or retrieves the size of the control.

> [!NOTE] > Supported only for devices running Smartphone 2002 and Pocket PC 2002 software or later.

type

string

Read

Always returns — text.

value

string

Read/Write

Sets or retrieves the value of the input type=text control.

Scripting Events

The following table shows items that Internet Explorer Mobile supports.

Event Comment

onblur

Occurs when an element loses focus either by the pointing device or by keypad navigation.

> [!NOTE] > Supported only for devices running Smartphone 2002 and Pocket PC 2002 software or later.

onchange

Occurs when the contents of the input type=text have changed and the user has committed the change (by leaving the input type=text control that has focus).

onfocus

Occurs when an element receives focus either by the pointing device or by tabbing navigation.

> [!NOTE] > Supported only for devices running Smartphone 2002 and Pocket PC 2002 software or later.

Scripting Methods

The following table shows items that Internet Explorer Mobile supports.

Method Arguments Comments

blur

 

syntax:

text.blur()

  • Simulates leaving the type=text control causing the onblur event to fire.

focus

 

syntax:

text.focus()

  • Sets focus to the input type=text control.

getAttribute

option

Syntax:

vAttrValue=text.getAttribute(sAttrName[,iFlags])

  • Returns the value of the specified attribute. If the attribute is not present then a NULL is returned.
    sAttrName is a String containing the name of the attribute.
    iFlags is an integer that specifies one or more of the following:
    0 (Default) Performs a property search that is not case-sensitive, and returns an interpolated value if the property is found.
    1 Performs a case-sensitive property search. To find a match, the uppercase and lowercase letters in sAttrName must exactly match those in the attribute name.
    2 Returns the value exactly as it was set in script or in the source document.

select

 

syntax:

text.select()

Requirements

Windows Mobile Pocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later

See Also

Concepts

Internet Explorer Mobile HTML Elements