72 out of 111 rated this helpful - Rate this topic

input type=text element | input type=text object

[This documentation is preliminary and is subject to change.]

Creates a single-line text entry control.

HTML 4.01 Specification, Section 17.4

Standards information

HTML information

Closing Tagforbidden
CSS Displayinline

DOM Information

Inheritance Hierarchy

 Node
  Element
   HTMLElement
     input type=text

Remarks

The SIZE attribute sets the number of visible characters in the INPUT type=text element. The MAXLENGTH attribute sets the maximum number of characters that can be entered.

Security Warning:  Using this object incorrectly can compromise the security of your application. When submitting text through INPUT type=text over an intranet or the Internet, validating the text string is recommended. For instance, you might validate the string for a restricted set of known, good values (such as letters and numbers) and ignore the rest. You should review the Security Considerations: Dynamic HTML before continuing.

Examples

This example uses the INPUT type=text element to create an empty text control that can contain 15 characters without requiring the user to scroll to read all of the text.


<INPUT TYPE=text VALUE="" NAME="textbox" SIZE=15>

This example uses script to detect the content of the text box and display it in a dialog box.


<SCRIPT>
function detectEntry()
{
    alert("Your name is " + textbox.value)
}
</SCRIPT>

See also

input
Reference
spellcheck
input
textArea

 

 

Build date: 3/8/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Issue with Mouse events and transparent background on Input elements and Textareas

Please consider the following article:
http://blog.rednael.com/2009/09/01/TrappingMouseEventsOnTransparentInputElementsOrTextareasInIE.aspx

It describes an issue when trying to trap mouse events on transparent Input elements (type=text) and Textarea elements.