// page init
jQuery(function(){
    initFormValidation();
});

function initFormValidation(){
	jQuery('.form-validate').formValidation();
}

/*
 * jQuery Form Validation plugin
 */
(function ($) {
	function FormValidation(options) {
		this.options = $.extend({
			dataRequired: 'validate',
			dataItem: '[data-validate]',
			inputWrapClass: '.form-item',
			submitButton: 'input[type=submit]',
			event: 'keyup change',
			successEvent: function(){}
		}, options);
		this.init();
	}

	FormValidation.prototype = {
		init: function () {
			this.findElements();
			this.events();
		},
		findElements: function () {
			this.form = jQuery(this.options.holder);
			this.requiredItems = this.form.find(this.options.dataItem);
			this.submitButton = this.form.find(this.options.submitButton);
		},
		events: function(){
			var self = this;
			self.requiredItems.on(self.options.event, function(){
				var item = jQuery(this);
				var val = item.val();
				self.validateInputs(item, val);
			});
			self.form.on('submit', function(){
				self.requiredItems.trigger('change'); // need for first load page with not empty form item
				var result = self.checkValidate();
				if(!result){
					return false
				}
			});
		},
		validateInputs: function(item, value){
			switch (item.data(this.options.dataRequired)){
				case 'required' :
					if(value === ""){
						item.closest(this.options.inputWrapClass).addClass('error').removeClass('correct');
					} else {
						item.closest(this.options.inputWrapClass).removeClass('error').addClass('correct');
					}
					break;
				case 'email' :
					var pattern = /^([a-z0-9_\.-])+@[a-z0-9-]+\.([a-z]{2,4}\.)?[a-z]{2,4}$/i;
					if(!pattern.test(value)){
						item.closest(this.options.inputWrapClass).addClass('error').removeClass('correct');
					} else {
						item.closest(this.options.inputWrapClass).removeClass('error').addClass('correct');
					}
					break;
				case 'required-number':
					var reg = /^[0-9]+$/;
					if(!reg.test(value) || value === ""){
						item.closest(this.options.inputWrapClass).addClass('error').removeClass('correct');
					} else {
						item.closest(this.options.inputWrapClass).removeClass('error').addClass('correct');
					}
					break;
				case 'required-select':
					if(value === ""){
						item.closest(this.options.inputWrapClass).addClass('error').removeClass('correct');
					} else {
						item.closest(this.options.inputWrapClass).removeClass('error').addClass('correct');

					}
					break;
			}
		},
		checkValidate: function(){
			var self = this;
			if(self.requiredItems.length !== self.form.find('.correct').length){
				self.requiredItems.each(function(){
					var item = jQuery(this);
					var val = item.val();
					self.validateInputs(item, val);
				});
				return false
			} else {
				if(typeof self.options.successEvent === 'function'){
					self.options.successEvent();
				}
				return true
			}
		}
	};

	// jquery plugin
	$.fn.formValidation = function (opt) {
		return this.each(function () {
			$(this).data('FormValidation', new FormValidation($.extend(opt, {holder: this})));
		});
	};
})(jQuery);
@@ -413,16 +413,68 @@
 hange',%0A
+%09%09%09errorClass: 'error',%0A%09%09%09correctClass: 'correct',%0A
 %09%09%09succe
@@ -1443,39 +1443,55 @@
 Class).addClass(
-'error'
+this.options.errorClass
 ).removeClass('c
@@ -1484,33 +1484,49 @@
 removeClass(
-'
+this.options.
 correct
-'
+Class
 );%0A%09%09%09%09%09%7D el
@@ -1594,35 +1594,67 @@
 ass(
-'error').addClass('
+this.options.errorClass).addClass(this.options.
 correct
-'
+Class
 );%0A%09
@@ -1849,39 +1849,55 @@
 Class).addClass(
-'error'
+this.options.errorClass
 ).removeClass('c
@@ -1890,33 +1890,49 @@
 removeClass(
-'
+this.options.
 correct
-'
+Class
 );%0A%09%09%09%09%09%7D el
@@ -2000,35 +2000,67 @@
 ass(
-'error').addClass('
+this.options.errorClass).addClass(this.options.
 correct
-'
+Class
 );%0A%09
@@ -2224,39 +2224,55 @@
 Class).addClass(
-'error'
+this.options.errorClass
 ).removeClass('c
@@ -2265,33 +2265,49 @@
 removeClass(
-'
+this.options.
 correct
-'
+Class
 );%0A%09%09%09%09%09%7D el
@@ -2375,35 +2375,67 @@
 ass(
-'error').addClass('
+this.options.errorClass).addClass(this.options.
 correct
-'
+Class
 );%0A%09
@@ -2560,23 +2560,39 @@
 ddClass(
-'error'
+this.options.errorClass
 ).remove
@@ -2597,25 +2597,41 @@
 veClass(
-'
+this.options.
 correct
-'
+Class
 );%0A%09%09%09%09%09
@@ -2703,35 +2703,67 @@
 ass(
-'error').addClass('
+this.options.errorClass).addClass(this.options.
 correct
-'
+Class
 );%0A%0A
@@ -2893,24 +2893,43 @@
 .find('.
+'+this.options.
 correct
-'
+Class
 ).length

add some classes