getValue

getValue(element) -> string | array

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().

How to reference form controls by their name

This method is consistent with other DOM extensions in that it requires an element ID as the string argument, not the name of the form control (as some might think). If you want to reference controls by their names, first find the control the regular JavaScript way and use the node itself instead of an ID as the argument.

For example, if you have an input named "company" in a form with an ID "contact":

var form = $('contact');
var input = form['company'];

Form.Element.getValue(input);

// but, the preferred call is:
$(input).getValue(); // we used the $() method so the node gets extended

// you can also use the shortcut
$F(input);

Note

An error is thrown ("element has no properties") if the element argument is an unknown ID.