// Form Validation
function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "Email address is required.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "Please check email address.\n";
       }
    }
return error;
}


// validate phone field
function checkPhone (strng) {
var error = "";
if (strng == "") {
	error = "Phone number is required.\n";
	return error;
}
var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
if (isNaN(parseInt(stripped)) || !(stripped.length >= 10)) error = "Unrecognized phone number format.\n";
return error;
}


// required text field
function isEmpty(strng, errorField) {
var error = "";
  if (strng.length == 0) {
     error = "The "+ errorField + " field is required.\n"
  }
return error;	  
}

// required menu selection
function checkDropdown(choice, errorField) {
var error = "";
    if (choice == 0) {
    error = "A valid selection is required for the "+ errorField +" field.\n";
    }    
return error;
}
