Javascript [Electronic resources] : The Definitive Guide (4th Edition) نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Javascript [Electronic resources] : The Definitive Guide (4th Edition) - نسخه متنی

David Flanagan

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید



Availability


JavaScript
1.0; enhanced in JavaScript 1.1

Inherits from/Overrides


Inherits from Input, HTMLElement


Synopsis

form.name
form.elements[i]

Properties


Text inherits properties from Input and HTMLElement and defines or
overrides the following:


value

A read/write string that specifies the
text displayed in the text input field. This text may have been
entered by the user, or it may be a default value specified by the
document or by a script. The initial value of this property is
specified by the value attribute of the
<input> tag that defines the Text object.
When the user types characters into the Text object, the
value property is updated to match the
user's input. If you set the value property
explicitly, the string you specify is displayed in the Text object.
This property also specifies the string that is sent to the server
when the form is submitted.


Methods


Text inherits the methods of Input and HTMLElement.


Event Handlers


Text inherits the event handlers of Input and HTMLElement and defines
or overrides the following:

onchange

Invoked when the user changes the value in the Text element and moves
the keyboard focus elsewhere. This event handler is not invoked for
every keystroke in the Text element, but only when the user completes
an edit.


HTML Syntax


A Text element is created with a
standard HTML <input> tag:

<form>
...
<input
type="text" // Specifies that this is a Text element
[ name="name" ] // A name you can use later to refer to this element
// Specifies the name property
[ value="default" ] // Default value transmitted when the form is submitted
// Specifies the defaultValue property
[ size="integer" ] // How many characters wide the element is
[ maxlength="integer" ] // Maximum allowed number of input characters
[ onchange="handler" ] // The onchange( ) event handler
>
...
</form>


Description


The Text element represents a text input field in a form. The
size attribute specifies the width, in characters,
of the input field as it appears on the screen, and the
maxlength attribute specifies the maximum number
of characters the user is allowed to enter.

Besides these HTML attributes, value is the main
property of interest for the Text element. You can read this property
to obtain the user's input or set it to display arbitrary
(unformatted) text in the input field.


Usage


Use the Password element instead of the Text element when the value
you are asking the user to enter is sensitive information, such as a
password that should not be displayed openly on the screen. Use a
Textarea element to allow the user to enter multiple lines of text.

When a form contains only one Text or Password element, the form is
automatically submitted if the user strikes the

Return key in that Text or Password element.
In many forms, this is a useful shortcut. In some, however, it can be
confusing if the user strikes

Return
and submits the form before entering input into other form elements,
such as Checkboxes and Radio buttons. You can sometimes minimize this
confusion by placing Text elements with their default submission
action at the bottom of the form.


See Also


Form, Input, Password, Textarea; HTMLInputElement in the DOM
reference section

/ 844