﻿function checkWholeForm(_inquiry) {
    var why = "";
    why += checkEmail(_inquiry.email.value);
    why += isEmpty1(_inquiry.nameid.value);
    why += isEmpty2(_inquiry.company.value);    
    why += isEmpty3(_inquiry.phone.value);
    why += checkDropdown(_inquiry.inquiry.selectedIndex);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

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

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

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


function checkDropdown(choice) {
var error = "";
    if (choice == 0) {
    error = "You didn't choose an option from the drop-down list.\n";
    }    
return error;
}    


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;    
}


