<!--



function CheckFields(){


    var why = "";
    why += checkName(document.forms[0].elements[0].value);
    why += checkEmailorPhone(document.forms[0].elements[1].value, document.forms[0].elements[2].value);
    //why += checkEmail(document.forms[0].elements[1].value);
    //why += checkPhone(document.forms[0].elements[2].value);
    //why += checkCity(document.forms[0].elements[4].value);
    //why += checkState(document.forms[0].elements[5].value);

if (why != "") {
       alert(why);
    }
else {submitForm()}
}

function checkEmailorPhone(email, phone) {
   var error="";

   var emailError="";
   var phoneError="";
   
   emailError = checkEmail(email);
   phoneError = checkPhone(phone);

   if (emailError != "" && phoneError != "") {
   error = "Please enter either your email or phone number so we can respond.\n";
   }
   return error;   
}

function checkEmail(strng) {
   var error="";
   if (strng == "") {
   error = "You didn't enter an 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 = "The email address contains illegal characters.\n";
       }
    }
return error;    
}


// phone number - strip out delimiters and check for 10 digits

function checkPhone(strng) {

var error = "";
if (strng == "") {
   error = "You didn't enter a phone number.\n";
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The phone number contains illegal characters.";
  
    }
    if (!(stripped.length == 10)) {
	error = "The phone number is the wrong length. Make sure you included an area code.\n";
    } 
return error;
}

// non-empty textbox - checkName

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


// non-empty textbox - checkPosition

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


// non-empty textbox - checkCity

function checkCity(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter the city where your school is located.\n"
  }
return error;	  
}


// non-empty textbox - checkState

function checkState(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter the state where your school is located.\n"
  }
return error;	  
}

function submitForm()
{
  document.forms[0].submit();
  //alert("Form submitted. Thank you!");
}

// -->
