Example 1

Calculations




(price * count)

(15%, not less than 15)

Source

<script>
	$(document).ready(function() {
		$('form').liveform();
	});
</script>
<form>
	<div>
		<label>price per item</label><br />
		<input type="text" name="price"/>
	</div>
	<div>
		<label>total items</label><br />
		<input type="text" name="count"/>
	</div>
	<div>
		<label>total price</label><br />
		<input type="text" name="total" data-formula="int(price) * int(count)" />
		(price * count)
	</div>
	<div>
		<label>duty</label><br />
		<input type="text" name="duty" data-formula="if(total > 0, if(total > 100, total * 0.15, 15), 0)" />
		(15%, not less than 15)
	</div>
</form>

Example 2

Fields visibility



Source

<script>
	$(document).ready(function() {
		$('form').liveform();
	});
</script>
<form>
	<div>
		<label>name</label><br />
		<input type="text" name="name"/>
	</div>
	<div>
		<label>have any job?</label>
		<input type="checkbox" name="job"/>
	</div>
	<div>
		<label>specialization</label><br />
		<input type="text" name="specialization" data-visibility="job" />
	</div>
</form>

Example 3

Required fields




Source

<script>
	$(document).ready(function() {
		$('form').liveform();
	});
</script>
<form>
	<div>
		<label>name</label><br />
		<input type="text" name="name"/>
	</div>
	<div>
		<label>specialization</label><br />
		<select name="specialization">
			<option value="">--select--</option>
			<option value="programmer">programmer</option>
			<option value="designer">designer</option>
			<option value="driver">driver</option>
		</select>
	</div>
	<div>
		<label>driver license</label><br />
		<input type="text" name="license" data-required="specialization='driver'" />
	</div>
</form>

Options

Option Type Description
inputcontainer jQuery selector Closest html node, that contains element (including label)
inputlabel jQuery selector Element label
requiredClass string Css class that will be assigned to required element
visibilityfn function(liveform, element, visible) Function that does field (in)visibile
requiredfn function(liveform, element, required) Function that does field (non-)required