﻿//check if the string received is a valid email
function isValidMail(emailStr)
{
	var RegEmail  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return RegEmail.test(emailStr);
}
//check if the string received is a valid website address
function isValidWebSiteAddress(websiteStr)
{
	var RegWebSite  = /(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
    return RegWebSite.test(websiteStr);
}
//check if the string received is valid
//if not display the error validation tag
function ValidateMail(emailStr,errDiv)
{
    if (isValidMail(emailStr))
    {
        errDiv.style.visibility = "hidden";
        return true;
    }
    else
    {
        errDiv.style.visibility = "visible";
        return false;
    }
}
//validate if the string is empty or not.
function ValidateNoneEmpty(txtStr,errDiv)
{
    if (txtStr.length > 0)
    {
        errDiv.style.visibility = "hidden";
        return true;
    }
    else
    {
        errDiv.style.visibility = "visible";
        return false;
    }
}
//check if the string received is valid
//if not display the error validation tag
function ValidateWebSite(webSiteStr,errDiv)
{
    if (isValidWebSiteAddress(webSiteStr))
    {
        errDiv.style.visibility = "hidden";
        return true;
    }
    else
    {
        errDiv.style.visibility = "visible";
        return false;
    }
}