Basic Examples Advanced

Installation

This plugin requires 3 things

  1. jQuery (Tested with v1.8.2). You can grab a CDN hosted copy here http://jquery.com/download/ or use the file provided in js/jquery/jquery.min.js

  2. The validator plugin: (js/dist/formValidator.js or or minified: js/dist/formValidator.min.js)

  3. Styling: css/styles.css

so you have:

<link rel="stylesheet" href="styles.css" type="text/css"/>

<script type='text/javascript' src='jquery.min.js'></script>

<script type='text/javascript' src='formValidator.min.js'></script>

Usage:

	/** 
	* Currently, this is a two part plugin.  
	* It requires assigning attributes to individual form elements, and then assigning the validateForm plugin to the form.
	*/

	//First, initialize some form fields:
	var options = {
		allowInput : /regex/, //set to restrict allowed input
		required : true, //is this field required?
		requiredMessage : "Address is required", //custom text alert for required fields
		message : "Enter your Address", //initialize informative message
		validateWith : function, //a custom function to validate against
		onSuccess : function //function callback after form is validated successfully - call this before submit
	}

	//initialze and assign to element
	$('#address').isNameField(options);

	//assign to form
	$('#myForm').validateForm();


	/**
	* There are methods you can call explicitly to validateForm
	*/

	//to reset the form manually to its initial state:
	$('#myForm').validateForm('resetForm');

	//to run form validation manually (instead of through form submit):
	$('#myForm').validateForm('runValidation');