function validateEmpty(id,title) {
    error = "";
    val = $("#"+id+"").val();
    if (val.length < 1) {
        $("#"+id+"").css({"border":"1px solid #880000","background":"#ffcccc"});
        error = title+" is a required field, blank entries are not allowed.\n\n";
    } else {
        $("#"+id+"").css({"border":"1px solid #c1c1c1","background":"#ffffff"});
    }
    //console.log(val);
    return error;
}
function validateEmptyTextarea(val,error_msg) {
    error = "";

    if (val.length < 1) {

        error = error_msg;
    }
    //console.log(val);
    return error;
}

function validateNames(id,title,length) {
    error = "";
    val = $("#"+id+"").val();
    var nc = new RegExp('^([a-zA-Z\\-\\.\\\'\\s]{1,'+length+'})$');
    //console.log(nc);
    if (!nc.test(val)) {
        $("#"+id+"").css({"border":"1px solid #880000","background":"#ffcccc"});
        error = "There is a problem with the "+title+" field.\nThe "+title+" field allows for letters, dashes, periods, apostrophes, and spaces with a max length of "+length+" characters.\n\n";
    } else {
        $("#"+id+"").css({"border":"1px solid #c1c1c1","background":"#ffffff"});
    }
    //console.log(error);
    return error;
}
function validateSpecific(id,title,reg,allows,length) {
    error = "";
    val = $("#"+id+"").val();
    var nc = new RegExp('^('+reg+'{'+length+'})$');
    //console.log(value);
    if (!nc.test(val)) {
        $("#"+id+"").css({"border":"1px solid #880000","background":"#ffcccc"});
        error = "There is a problem with the "+title+" field.\nThe "+title+" field allows for "+allows+" with a max length of "+length+" characters.\n\n";
    } else {
        $("#"+id+"").css({"border":"1px solid #c1c1c1","background":"#ffffff"});
    }
    return error;
}
function validateAddress(id,title,length) {
    error = "";
    val = $("#"+id+"").val();
    var ac = new RegExp('^([a-zA-Z0-9\\s\\.\\#\\,\\-]{1,'+length+'})$');
    if (!ac.test(val)) {
         $("#"+id+"").css({"border":"1px solid #880000","background":"#ffcccc"});
        error = "There is a problem with the "+title+" field.\nThe "+title+" field allows for letters, number , dashes, periods, apostrophes, commas, pound sign, and spaces with a max length of "+length+" characters.\n\n";
    } else {
        $("#"+id+"").css({"border":"1px solid #c1c1c1","background":"#ffffff"});
    }
    return error;
}
function validateZip(id,title) {
    error = "";
    val = $("#"+id+"").val();
    //us right now
    zc = /^([0-9]{5})$/;
    
    if (!zc.test(val)) {
         $("#"+id+"").css({"border":"1px solid #880000","background":"#ffcccc"});
        error = "There is a problem with the "+title+" field.\nThe "+title+" requires a 5 digit US zipcode.\n\n";
    } else {
        $("#"+id+"").css({"border":"1px solid #c1c1c1","background":"#ffffff"});
    }
    return error;
}
function validateLowerNames(id,title,length) {
    error = "";
    val = $("#"+id+"").val();
    var nc = new RegExp('^([a-z]{1,'+length+'})$');
    //console.log(nc);
    if (!nc.test(val)) {
        $("#"+id+"").css({"border":"1px solid #880000","background":"#ffcccc"});
        error = "There is a problem with the "+title+" field.\nThe "+title+" field allows for lowercase letters with a max length of "+length+" characters.\n\n";
    } else {
        $("#"+id+"").css({"border":"1px solid #c1c1c1","background":"#ffffff"});
    }
    //console.log(val);
    //console.log(val.length);
    return error;
}
function validateEmail(id) {
    error = "";
    val = $("#"+id+"").val();
    ec = /^([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})(\]?)$/;
    if (!ec.test(val)) {
        $("#"+id+"").css({"border":"1px solid #880000","background":"#ffcccc"});
        error = "There is a problem with the email field.\nThe email should contain a properly formatted email address.\n\n";
    } else {
        $("#"+id+"").css({"border":"1px solid #c1c1c1","background":"#ffffff"});
    }
    //console.log(error);
    //console.log(id);
    //console.log(val);
    //console.log(val.length);
    return error;
}
function validatePassword(id) {
    error = "";
    val = $("#"+id+"").val();
    pc = /^(?=.*\d).{8,12}$/;
    if (!pc.test(val)) {
       $("#"+id+"").css({"border":"1px solid #880000","background":"#ffcccc"});
       error = "There is a problem with the password field.\nThe password should contain between 8 and 12 characters including at least one number.\nExample: pumpk1ns.\n\n";
    } else {
        $("#"+id+"").css({"border":"1px solid #c1c1c1","background":"#ffffff"});
    }
    return error;
}
function validatePhone(id,title) {
    error = "";
    val = $("#"+id+"").val();
    pc = /^([0-9]{10})$/;
    if (!pc.test(val)) {
        $("#"+id+"").css({"border":"1px solid #880000","background":"#ffcccc"});
        error = "There is a problem with the "+title+" field.\nThe "+title+" should be 10 digits long with no spaces or dashes.\nExample 8008675309\n\n";
    } else {
        $("#"+id+"").css({"border":"1px solid #c1c1c1","background":"#ffffff"});
    }
    return error;
}
function validateSecurity(id) {
    error = "";
    val = $("#"+id+"").val();
    if (val < 0 || val > 10) {
        $("#"+id+"").css({"border":"1px solid #880000","background":"#ffcccc"});
        error = "The security field should be between 0 and 10\n\n";
    } else {
        $("#"+id+"").css({"border":"1px solid #c1c1c1","background":"#ffffff"});
    }
    return error;
}
function validateIHM(id) {
    error = "";
    val = $("#"+id+"").val();
    ihmc = /^([0-9]{8})$/;
    if (!ihmc.test(val)) {
        $("#"+id+"").css({"border":"1px solid #880000","background":"#ffcccc"});
        error = "The IHM field should be an 8 digit number.\n\n";
    } else {
        $("#"+id+"").css({"border":"1px solid #c1c1c1","background":"#ffffff"});
    }
    return error;
}
function validateRadio(clss,clor,dval,val,title) {
    error = "";
    
    if (val == dval) {
        error = "The "+title+" section requires a selection, please make a selection to continue.\n\n";
        $("."+clss+"").css({"border":"1px solid #880000","background":"#ffcccc"});
    } else {
        $("."+clss+"").css({"border":"none","background":clor});
    }
    return error;
}
function validateNumeric(id,title,length) {
    error = "";
    val = $("#"+id+"").val();
    pc = new RegExp('^([0-9]{'+length+'})$');
    if (!pc.test(val)) {
        $("#"+id+"").css({"border":"1px solid #880000","background":"#ffcccc"});
        error = "There is a problem with the "+title+" field.\nThe "+title+" field should be "+length+" digits long.\n\n";
    } else {
        $("#"+id+"").css({"border":"1px solid #c1c1c1","background":"#ffffff"});
    }
    return error;
}
function validateSelect(id,title) {
    error = "";
    val = $("#"+id+"").val();
    if (val.length < 1) {
        $("#"+id+"").css({"border":"1px solid #880000","background":"#ffcccc"});
        error = "The "+title+" section requires a selection, please make a selection to continue.\n\n";
    } else {
        $("."+id+"").css({"border":"none","background":"#ffffff"});
    }
    return error;
}
function validateAlpha(id,title) {
    error = "";
    val = $("#"+id+"").val();
    nc = new RegExp('^([a-zA-Z0-9\\-\\s\\.]+)$');
    if (!nc.test(val)) {
        $("#"+id+"").css({"border":"1px solid #880000","background":"#ffcccc"});
        error = "There is a problem with the "+title+" field.\nThe "+title+" field allows for letters, dashes, periods,  and spaces.\n\n";
    } else {
        $("#"+id+"").css({"border":"1px solid #c1c1c1","background":"#ffffff"});
    }
    //console.log(error);
    return error;
}