﻿function checkWholeForm(hachflow) {
    var why = "";
    why += checkEmail(hachflow.em.value);
    why += isEmpty1(hachflow.fn.value);
    why += isEmpty2(hachflow.ln.value);
    why += isEmpty3(hachflow.o.value);
    why += isEmpty4(hachflow.a1.value);
    why += isEmpty5(hachflow.ci.value);
    why += isEmpty6(hachflow.sp.value);
    why += isEmpty7(hachflow.pc.value);
    why += isEmpty8(hachflow.co.value);
    why += isEmpty9(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 first name.\n"
  }
return error;     
}

// Last Name Validate

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

// Organization Validate

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

// Address One Validate

function isEmpty4(strng) {
var error = "";
  if (strng.length == 0) {
     error = "You did not enter an address.\n"
  }
return error;     
}

// City Validate

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

// State/Province Validate

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

// Postal Code Validate

function isEmpty7(strng) {
var error = "";
  if (strng.length == 0) {
     error = "You did not enter your postal code.\n"
  }
return error;     
}

// Country Validate

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

// Telephone Validate

function isEmpty9(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;    
}


