Prototype - Form.Element Management


Advertisements


Form.emement is a submodule of Form which deals with specific form controls on INPUT, SELECT and TEXTAREA elements.

Form.Element is also aliased Field. Following two forms are equivalent −

Form.Element.activate('myfield')

is equivalent to:

Field.activate('myfield');

Which in turn equivalent to:

$('myfield').activate()

Here is a complete list of all the methods related to Form.Element.

Prototype Event Methods

NOTE − Make sure you at least have the version 1.6 of prototype.js.

S.No. Method & Description
1. activate()

Gives focus to a form control and selects its contents if it is a text input.

2. clear()

Clears the contents of a text input.

3. disable()

Disables a form control, effectively preventing its value to be changed until it is enabled again.

4. enable()

Enables a previously disabled form control.

5. focus()

Gives keyboard focus to an element.

6. getValue()

Returns the current value of a form control. A string is returned for most controls; only multiple select boxes return an array of values. The global shortcut for this method is $F().

7. present()

Returns true if a text input has contents, false otherwise.

8. select()

Selects the current text in a text input.

9. serialize()

Creates an URL-encoded string representation of a form control in the name=value format.


prototype_form_management.htm

Advertisements