Script 15.6 Calculator with error messages

Includes javascript 15.7 - Uses jQuery to process a form and indicate any error messages inline.

Output

Widget Cost Calculator

Please enter a valid quantity!

Please enter a valid price!

Please enter a valid tax!

Source
	<!-- Script 15.6 - calculator #2 -->
<h1>Widget Cost Calculator</h1>
<p id="results"></p>
<form action="<?php echo htmlentities( $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'] ); ?>" method="post" id="calculator">
	<p id="quantityP">
		<label for="quantity">Quantity</label>
		<input type="text" name="quantity" id="quantity" />
		<span class="errorMessage" id="quantityError">Please enter a valid quantity!</span>
	</p>
	<p id="priceP">
		<label for="price">Price</label>
		<input type="text" name="price" id="price" />
		<span class="errorMessage" id="priceError">Please enter a valid price!</span>
	</p>
	<p id="taxP">
		<label for="tax">Tax (%)</label>
		<input type="text" name="tax" id="tax" />
		<span class="errorMessage" id="taxError">Please enter a valid tax!</span>
	</p>
	<p>
		<input type="submit" name="submit" id="submit" value="Calculate!" />
	</p>
</form>