fio

Download as .zip Download as .tar.gz View on GitHub

"fio" (form IO) is a utility for getting/setting data in input and select form fields by following a set of semantics.

It follows these semantics:

Requirements

Download

Install

AMD

<script src="require.js"></script>
<script>require(['fio'], function(fio) { ... })</script>

Traditional

<script src="jquery.js"></script>
<script src="fio.js"></script>

API

fio.get(selector)

Gets the input value given the selector.

fio.set(selector, value)

Sets the input value for the selector.

fio.coerce(value, type)

Coerces some value for the given type. This is generally performed after getInputValue is used.

fio.check(value, type)

Validates a value is of the given type. Returns a boolean denoting the result.

Examples

Checkboxes:

<input type=checkbox name=cbox1 value=foo checked>
<input type=checkbox name=cbox1 value=bar>
<input type=checkbox name=cbox1 value=baz checked>
fio.get('[name=cbox1]'); // ['foo', 'baz']

Multiple Inputs

<input name=range1 value=1>
<input name=range1 value=2>
fio.get('[name=range1]'); // [1, 2]

Disable Input

<input name=range2 value=1>
<input name=range2 value=2 disabled>
fio.get('[name=range2]'); // 1