﻿(function($) {
    $.fn.validation = function() {
        var error = 0;
        $('.required-field', this).each(function() {
            var input = $(this).attr("value");
            if (input == "" || input == null) {
                //$('span.error-message', this).remove();
                //$(this).append('<span class="error-message"><span class="error"></span></span>');
                //$('span.error', this).html('Please fill in this mandatory field.');
                $(this).addClass("error-highlight");
                error++;
            } else {
                //$('span.error-message', this).remove();
                $(this).removeClass("error-highlight");
            }
        });
        if (error == 0) {            
            return true;
        } else {
        //$('.required-field', this)[0].parent.append('<span class="error-message"><span class="error">Please fill in this mandatory field.</span></span>');
            return false;            
        }
    };
})(jQuery);
