/*
http://tetlaw.id.au/view/javascript/really-easy-field-validation

Multiple options can be combined to create a complex validator and they can also
enhance your custom validation function. Here are the available options and
example usage below:

Validation.add('class-name', 'Error message text', {
     pattern : new RegExp("^[a-zA-Z]+$","gi"), // only letter allowed
     minLength : 6, // value must be at least 6 characters
     maxLength : 13, // value must be no longer than 13 characters
     min : 5, // value is not less than this number
     max : 100, // value is not more than this number
     notOneOf : ['password', 'PASSWORD'], // value does not equal anything in this array
     oneOf : ['fish','chicken','beef'], // value must equal one of the values in this array
     is :  '5', // value is equal to this string
     isNot : 'turnip', //value is not equal to this string
     equalToField : 'password', // value is equal to the form element with this ID
     notEqualToField : 'username', // value is not equal to the form element with this ID
     include : ['validate-alphanum'] // also tests each validator included in this array of validator keys (there are no sanity checks so beware infinite loops!)
});
*/

function formCallback(result, form) {
	window.status = "validation callback for form '" + form.id + "': result = " + result;
}

var valid = new Validation('freeform', {onFormValidate : formCallback});
Validation.addAllThese([
	['validate-yes-no', 'Please select yes or no.', {
		oneOf : ['yes','no','Yes', 'No']
	}],
	['validate-password', 'Your password must be more than 5 characters and not be "password."', {
    minLength : 5,
    notOneOf : ['password','PASSWORD', 'Password']
	}],
	// 'create_password' field must exist in the form for this validation
	['validate-confirm-password', 'Your confirmation password does not match your first password, please try again.', {
		equalToField : 'create_password'
	}],
	['validate-one-char', 'Value must be one character long.', {
		minLength : 1,
		maxLength : 1
	}],
	['validate-text-length', 'Please shorten your response.', {
		maxLength : 64000
	}],
	['validate-10-max', 'Value must be less than 10 characters.', {
		maxLength : 10
	}],
	['validate-16-max', 'Value must be less than 16 characters.', {
		maxLength : 16
	}],
	['validate-32-max', 'Value must be less than 32 characters.', {
		maxLength : 32
	}],
	['validate-64-max', 'Value must be less than 64 characters.', {
		maxLength : 64
	}],
	['validate-128-max', 'Value must be less than 128 characters.', {
		maxLength : 128
	}],
	['validate-255-max', 'Value must be less than 255 characters.', {
		maxLength : 255
	}],
	['validate-500-max', 'Value must be less than 500 characters.', {
		maxLength : 500
	}]
]);

