
function isEmpty(inputStr){
	if (inputStr == null ||  inputStr == ""){
		return true
	}
	return false
}

function isNumber(inputVal){
	oneDecimal = false;
	inputStr = inputVal.toString();
	for (var i =0; i <  inputStr.length; i++){
		var oneChar = inputStr.charAt(i)
		if (oneChar == "." && !oneDecimal){
			oneDecimal = true;
			continue;
		}
		if (oneChar < "0" || oneChar > "9"){
			return false;
		}
	}
	return true;
}

function inRange(inputStr, minnum, maxnum){
	/*function to determine if value is in acceptable range*/
	var num;
	num = parseInt(inputStr)
	if 	(num <  minnum || num > maxnum){
		return false;
	}
	return true;
}

function checkEmail (inputStr) {
var error="";
if (inputStr == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(inputStr))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (inputStr.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}

function checkPhone (inputStr) {
var error = "";
if (inputStr == "") {
   error = "You didn't enter a phone number.\n";
}

var stripped = inputStr.replace(/[\(\)\.\-\ext\ ]/gi, ''); //strip out acceptable non-numeric characters
    if (!isNumber(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;
}

function checkFax (inputStr) {
var error = "";

var stripped = inputStr.replace(/[\(\)\.\-\ ]/g, '');  //strip out acceptable non-numeric characters
    if (!isNumber(stripped)) { 
       error = "The fax number contains illegal characters.";
  
    }
    if (stripped.length < 10) {
	error = "The fax number is the wrong length. Make sure you included an area code.\n";
    } 

return error;
}
