﻿(function($){
    $.fn.Validation = function(){};
    
    $.fn.Validation.IsValidText = function(strValue,blnRequired,intLength){
        
        if(strValue != null){
            strValue = strValue.replace(/^\s+/, '');
        
            if(intLength != null){
                if(isNaN(intLength) == false){
                    if(intLength < strValue.length){
                        return false;
                    }
                }
            }
        
            if(blnRequired){
                if(strValue.length == 0){
                    return false;
                }
            }
        }else{
            return false;
        }
        
        return true;
    };
    
    
    $.fn.Validation.IsValidEmail = function(strValue){
        var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        
        if(strValue != null){
            if(! filter.test(strValue)){
                return false;
            }
        }else{
            return false;
        }
        
        return true;
    };
    
    
    $.fn.Validation.IsValidExpression = function(strValue,strExpression){
        if(strValue != null){
            if(! strValue.test(strExpression)){
                return false;
            }
        }else{
            return false;
        }
        
        return true;
    };
    
})(jQuery);
