function validateUploadFormOnSubmit(uploadform) {
var reason = "";

  reason += validateFullname(uploadform.fullname);
  reason += validateEmail(uploadform.email);
  reason += validatePhoneno(uploadform.phoneno);



  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }
    return true;
}







function validateEmpty(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "The required field has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;  
}




function validateFullname(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter a Full Name.\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 150)) {
        fld.style.background = 'Yellow'; 
        error = "The Full Name is the wrong length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = 'Yellow'; 
        error = "The Full Name contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}







function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}
function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = 'Yellow';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = 'Yellow';
        error = "The email address contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}






function validatePhoneno(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter your Phone Number.\n"
    } else if ((fld.value.length < 3) || (fld.value.length > 150)) {
        fld.style.background = 'Yellow'; 
        error = "The Phone Number is the wrong length.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}




function validateSpecialnotes(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter any Comments.\n"
    } else if ((fld.value.length < 3) || (fld.value.length > 150)) {
        fld.style.background = 'Yellow'; 
        error = "The Comments is the wrong length.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}












function validatePhonePre(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter your First Phone Number.\n"
    } else if ((fld.value.length < 3) || (fld.value.length > 150)) {
        fld.style.background = 'Yellow'; 
        error = "The Phone Number is the wrong length.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}






function validatePhonePost(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter your Second Phone Number.\n"
    } else if ((fld.value.length < 3) || (fld.value.length > 150)) {
        fld.style.background = 'Yellow'; 
        error = "The Phone Number is the wrong length.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}







function validateCellArea(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter your Cell Number Area.\n"
    } else if ((fld.value.length < 3) || (fld.value.length > 150)) {
        fld.style.background = 'Yellow'; 
        error = "The Cell Number Area is the wrong length.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}





function validateCellPre(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter your First Cell Number.\n"
    } else if ((fld.value.length < 3) || (fld.value.length > 150)) {
        fld.style.background = 'Yellow'; 
        error = "The Cell Number is the wrong length.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}






function validateCellPost(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter your Second Cell Number.\n"
    } else if ((fld.value.length < 3) || (fld.value.length > 150)) {
        fld.style.background = 'Yellow'; 
        error = "The Cell Number is the wrong length.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}




function validateAddress1(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter your Address.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;
}



function validateCity(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter your City.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;
}



function validateState(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter your State.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;
}



function validateZipcode(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "You didn't enter your Zipcode.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;
}





function validatePrivacybox(fld) {
    var error = "";
 
	if (fld.checked == false ) {
        fld.style.background = 'Yellow'; 
        error = "You must select Pricacy Box.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;
}



