﻿function checkWholeForm(upload_form) {
    var why = "";
    why += checkEmail(upload_form.stremail.value);
    why += isEmpty1(upload_form.first.value);
    why += isEmpty2(upload_form.last.value);    
    why += isEmpty3(upload_form.strtitle.value);
    why += isEmpty4(upload_form.strcompany.value);
    why += isEmpty5(upload_form.straddress1.value);
    why += isEmpty6(upload_form.strcity.value);
    why += isEmpty7(upload_form.strstate.value);
    why += isEmpty8(upload_form.strzip.value);
    why += isEmpty9(upload_form.strphone.value);
    why += isEmpty10(upload_form.strfax.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

// first name check

function isEmpty1(strng) {
var error = "";
  if (strng.length == 0) {
     error = "You did not enter your first name.\n"
  }
return error;     
}

// last name check

function isEmpty2(strng) {
var error = "";
  if (strng.length == 0) {
     error = "You did not enter your last name.\n"
  }
return error;     
}

// title check

function isEmpty3(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter your title.\n"
  }
return error;     
}

// company check

function isEmpty4(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please provide your company name.\n"
  }
return error;     
}

// address Check

function isEmpty5(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter your address.\n"
  }
return error;     
}

// city check

function isEmpty6(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter your city.\n"
  }
return error;     
}

// state check

function isEmpty7(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter your state.\n"
  }
return error;     
}

// zip code check

function isEmpty8(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please provide your zip code.\n"
  }
return error;     
}

// phone check

function isEmpty9(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter your telephone number.\n"
  }
return error;     
}

// fax code check

function isEmpty10(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please provide a fax number.\n"
  }
return error;     
}

// Email Check

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "Please enter a Email Address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid Email Address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "This is not a true Email Address.\n";
       }
    }
return error;    
}



