Prototype JavaScript framework

namespace Form

Related utilities

$F

Instance methods

  • disable

    Form#disable() -> Element
    Form.disable(form) -> Element

    Disables the form as a whole. Form controls will be visible but uneditable.

    This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.

  • enable

    Form#enable() -> Element
    Form.enable(form) -> Element

    Enables a fully- or partially-disabled form.

    This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.

  • findFirstElement

    Form#findFirstElement() -> Element
    Form.findFirstElement(form) -> Element

    Finds the first non-hidden, non-disabled control within the form.

    This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.

  • focusFirstElement

    Form#focusFirstElement() -> Element
    Form.focusFirstElement(form) -> Element

    Gives keyboard focus to the first element of the form. Returns the form.

    This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.

  • getElements

    Form#getElements() -> [Element...]
    Form.getElements(form) -> [Element...]

    Returns a collection of all controls within a form.

    This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.

  • getInputs

    Form#getInputs( [, type [, name]]) -> [Element...]
    Form.getInputs(form [, type [, name]]) -> [Element...]
    • type (String) – A value for the type attribute against which to filter.
    • name (String) – A value for the name attribute against which to filter.

    Returns a collection of all INPUT elements in a form.

    Use optional type and name arguments to restrict the search on these attributes.

    This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.

  • request

    Form#request([options]) -> Ajax.Request
    • options (Object) – Options to pass along to the Ajax.Request constructor.

    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 one to override the HTTP method and/or specify additional parameters and callbacks.

  • serialize

    Form#serialize([, options]) -> String | Object
    Form.serialize(form[, options]) -> String | Object
    • options (Object) – A list of options that affect the return value of the method.

    Serialize form data to a string suitable for Ajax requests.

    If options.hash is true, returns an object of key/value pairs instead (where keys are control names).

    This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.

Class methods

  • reset

    Form.reset(form) -> Element

    Resets a form to its default values.

  • serializeElements

    Form.serializeElements(elements[, options]) -> String | Object
    • elements (Array) – A collection of elements to include in the serialization.
    • options (Object) – A list of options that affect the return value of the method.

    Serialize an array of form elements to a string suitable for Ajax requests.

    If options.hash is true, returns an object of key/value pairs instead (where keys are control names).