Clean Form Validation

Example of Simple Form Validation


Code

Here is the complete example code (form and script). Download and include the cleanValidator.js file.

Html:
  1. <form id="example" action="index.html" method="get">
  2.     <div>
  3.         <label>Name:</label> <input id="name" name="name" type="text" /></div>
  4.     <div>
  5.         <label>Email:</label> <input id="email" name="email" type="text" /></div>
  6.     <div>
  7.         <label>Number:</label> <input id="number" name="number" type="text" /></div>
  8.     <div>
  9.         <br /><input type="submit" value="Clean Validation!" /></div>
  10. </form>
  11. <script type="text/javascript">
  12.     cleanValidator.init({
  13.         formId: 'example,
  14.         inputColors: ['#EDEDED', '#FFFFFF'],
  15.         errorColors: ['#FFFF99', '#CF3339'],
  16.         isRequired: ['name','email','number'],
  17.         isEmail: ['email'],
  18.         isNumeric: ['number']
  19.     })
  20. </script>

Custom colors: inputColors and errorColors
Custom validation rules: rule: [id]