//----------------------------------------------
// Generic Form Validation Script
// Provides functions that are called on page
// format is check[FieldType] i.e. checkPhone
// last update: checkbox 10/2/2003 dn
//----------------------------------------------

//Check Zip Code: filled out / numeric
function checkZip (strng) {
	if (strng == "") {
		alert ("Please enter a zip code address.\n");
		return false;
	} 
	else {
		if ((isNaN(parseFloat(strng)))) {
			alert ('Please enter a numeric value for zip code.');
			return false;
		}
    }   
	return true;
}

//Check Phone (simple): filled out / numeric
function checkPhone (strng) {
	if (strng == "") {
		alert ("Please enter a phone number.\n");
		return false;
	} else {
		if ((isNaN(parseFloat(strng)))) {
			alert ('Please enter a numeric value for phone number.');
			return false;
		}
    }   
	return true;
}

//Check an email address: filled out / format / illegal chars
function checkEmail (strng) {
	if (strng == "") {
		alert ("Please enter an email address.\n");
		return false;
	}
	var emailFilter=/^.+@.+\..{2,3}$/;
	if (!(emailFilter.test(strng))) { 
		alert ("Please enter a valid email address.\n");
		return false;	   
	}
    else {
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
		if (strng.match(illegalChars)) {
			alert ("The email address you entered contains illegal characters.\n");
			return false;
		}
    }   
	return true;
}

//Check to see if one out of group of checkboxes is checked: checked
function checkCheckboxes(strng) {
	var anySelected=false;
	for(var i=0; i< strng.length; i++)
		{
			if(strng[i].type=="checkbox" && strng[i].checked) anySelected=true;
		}
		if(!anySelected)
		{
			alert("Pick check at least one choice.");
			return false;
		}
	return true;
}

