function validatorMailingList(txt_name, txt_email) {
    var name = validateAlphaNum(txt_name);
    var email = validateEmail(txt_email);
    
    if(name == false) {
        txt_name.style.background = "yellow";
    } else {
        txt_name.style.background = "white";
    }
    
    if(email == false) {
        txt_email.style.background = "yellow";
    } else {
        txt_email.style.background = "white";
    }

    // if both inputs are valid, proceed to submit
    if(name != false && email != false) {
        document.forms["form_mailingList"].submit();
    }
    
}


//
////-------------------------------------------
// function to test if input is composed only of letters, numbers, some symbols, and spaces
function validateAlphaNum(form) {
    var result = /^[\sa-zA-Z0-9\&\'\,\.\-\"\!\?\/ ]+$/.test(form.value);
    return result;
}
//-------------------------------------------


//-------------------------------------------
// function to test if input is composed only of letters and spaces
function validateAlpha(form) {
    var result = /^[\sa-zA-Z ]+$/.test(form.value);
    return result;
}
//-------------------------------------------


//-------------------------------------------
// function to test if input is composed only of numbers and spaces
function validateNum(form) {
    var result = /^[\s0-9-() ]+$/.test(form.value);
    return result;
}
//-------------------------------------------


//-------------------------------------------
// function to test if input is a valid email format
function validateEmail(form) {
    var result = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/.test(form.value);
    return result;
}
//-------------------------------------------
