SUPERSEEDED PLEASE SEE ‘Really Easy Field Validation with JQuery‘
from http://tetlaw.id.au/view/javascript/really-easy-field-validation
Include the scripts
<script src="prototype.js" type="text/javascript"><!--mce:0--></script> <script src="validation.js" type="text/javascript"><!--mce:1--></script>
use the class attribute to specify the type of validation
<input id="field1" class="required validate-number" name="field1" />
You then activate validation by passing the form or form’s id attribute like this:
<script type="text/javascript"><!--mce:2--></script>
options for the class attribute are listed below
- required (not blank)
- validate-number (a valid number)
- validate-digits (digits only)
- validate-alpha (letters only)
- validate-alphanum (only letters and numbers)
- validate-date (a valid date value)
- validate-email (a valid email address)
- validate-url (a valid URL)
- validate-date-au (a date formatted as; dd/mm/yyyy)
- validate-currency-dollar (a valid dollar value)
- validate-selection (first option e.g. ‘Select one…’ is not selected option)
- validate-one-required (At least one textbox/radio element must be selected in a group – see below*)
Tags: form checking, javascript, validation