﻿function checkWholeForm(hachflow) {
    var why = "";
    why += checkEmail(hachflow.eAdd.value);
    why += isEmpty1(hachflow.cName.value);
    why += isEmpty2(hachflow.fName.value);
    why += isEmpty3(hachflow.lName.value);
    why += isEmpty4(hachflow.tel.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

// First Name Validate

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

// Last Name Validate

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

// Organization Validate

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

// Address One Validate

function isEmpty4(strng) {
var error = "";
  if (strng.length == 0) {
     error = "You did not enter your telephone 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;    
}


