﻿function CheckRegExMatch(strRegEx, strValue)
{
    var objRegEx = new RegExp(strRegEx);
    return objRegEx.test(strValue);
}

function CheckValidInput(strValue)
{
    return CheckRegExMatch(/[^(\/\*)|(\*\/)|(@@)|(--)|(<)|(>)]/, strValue);
}

function CheckValidInteger(strValue)
{
    if ( CheckValidInput(strValue) )
        return CheckRegExMatch(/^([0-9])+$/, strValue);
    else
        return false;    
}

function CheckValidDecimal(strValue)
{
    if ( CheckValidInput(strValue) )
        return CheckRegExMatch(/^([0-9])+(([.,])*([0-9])+)*$/, strValue);
    else
        return false;    
}

function CheckValidName(strValue)
{
    if ( CheckValidInput(strValue) )
        return CheckRegExMatch(/^(\D)*$/, strValue);
    else
        return false;
}

function CheckValidEmail(strValue)
{
    if ( CheckValidInput(strValue) )
        return CheckRegExMatch(/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/, strValue);
    else
        return false;
}

function CheckValidUrl(strValue)
{
    if ( CheckValidInput(strValue) )
        return CheckRegExMatch(/(http(s)?|ftp(s)?):\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?/, strValue);
    else
        return false;
}