namespace Form.Element
Description
Utilities for dealing with form controls in the DOM.
This is a collection of methods that assist in dealing with form controls. They provide ways to focus, serialize, disable/enable or extract current value from a specific control.
Note that nearly all these methods are available directly on input,
select, and textarea elements. Therefore, these are equivalent:
Form.Element.activate('myfield');
$('myfield').activate();
Naturally, you should always prefer the shortest form suitable in a situation. Most of these methods also return the element itself (as indicated by the return type) for chainability.
Class methods
-
clear #
Form.Element.clear(element) ⇒ Element
Form#Element.clear() ⇒ ElementClears the contents of a text input. Returns the element.
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.
-
disable #
Form.Element.disable(element) ⇒ Element
Form#Element.disable() ⇒ ElementDisables a form control, effectively preventing its value from changing until it is enabled again.
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.Element.enable(element) ⇒ Element
Form#Element.enable() ⇒ ElementEnables a previously disabled form control.
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.
-
focus #
Form.Element.focus(element) ⇒ ElementGives keyboard focus to an element. Returns the element.
-
getValue #
Form.Element.getValue(element) ⇒ String | Array
Form#Element.getValue() ⇒ String | ArrayReturns the current value of a form control.
A string is returned for most controls; only multiple
selectboxes return an array of values.The global shortcut for this method is
$F.Alias of:
$FThis 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.
-
present #
Form.Element.present(element) ⇒ Element
Form#Element.present() ⇒ ElementReturns
trueif a text input has contents,falseotherwise.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.
-
select #
Form.Element.select(element) ⇒ ElementSelects the current text in a text input. Returns the element.
-
serialize #
Form.Element.serialize(element) ⇒ String
Form#Element.serialize() ⇒ StringReturns a URL-encoded string representation of a form control in the
name=valueformat.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.
-
setValue #
Form.Element.setValue(element, value) ⇒ Element
Form#Element.setValue(value) ⇒ ElementSets
valueto be the value of the form control. Returns the element.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.