Web | This Site

Learn Prototype
Prototype Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# Prototype Form Management

Prototype provides an easy way to manage HTML forms. Prototype's Form is a namespace and a module for all things form-related, packed with form manipulation and serialization goodness.

While it holds methods dealing with forms as whole, its sub module Form.Element deals with specific form controls.

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

# Prototype Form Methods:

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

Methods | Description
--- | ---
disable() | Disables the form as whole. Form controls will be visible but uneditable.
enable() | Enables a fully or partially disabled form.
findFirstElement() | Finds first non-hidden, non-disabled form control.
focusFirstElement() | Gives keyboard focus to the first element of the form.
getElements() | Returns a collection of all form controls within a form.
getInputs() | Returns a collection of all INPUT elements in a form. Use optional type and name arguments to restrict the search on these attributes.
request() | A convenience method for serializing and submitting the form via an Ajax.Request to the URL of the form's action attribute. The options parameter is passed to the Ajax.Request instance, allowing to override the HTTP method and to specify additional parameters.
reset() | Resets a form to its default values.
serialize() | Serialize form data to a string suitable for Ajax requests (default behavior) or, if optional getHash evaluates to true, an object hash where keys are form control names and values are data.
serializeElements() | Serialize an array of form elements to a string suitable for Ajax requests (default behavior) or, if optional getHash evaluates to true, an object hash where keys are form control names and values are data.

Advertisement

Online Image Processing

Indian Baby Names