﻿//call the validation and post to salesforce as needed
function SetupSalesForcePost(validationGroupName)
{
    var isValid = Page_ClientValidate(validationGroupName);
    if(isValid)
    {
        PostSalesForce();
    }

    return false;
}


//Check if the element has a value
function isRequiredElementValid(elementName)
{
    var frmElement = MM_findObj(elementName);
    
    if(frmElement != null)
    {
        if(frmElement.value.length > 0)
           return true;
    }
    return false;
}

//check if the email is a valid format
function isEmailValid(elementName)
{
    var frmElement = MM_findObj(elementName);
    
    if(frmElement != null)
    {
        if(frmElement.value.length > 0)
        {
            var reg = new RegExp("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$", "i");
            if(reg.test(frmElement.value))
                return true;
        }
    }
    return false;
}


//Check if the element has a value
function isInputElementValid(elementName, defaultValue)
{
    var frmElement = MM_findObj(elementName);
    
    if(frmElement != null)
    {
        if(frmElement.value.toLowerCase() != defaultValue.toString().toLowerCase())
           return true;
    }
    return false;
}

