/* Example in
function validateForm(form) {
    var why = "";
	why += isEmpty(form.FirstName, 'Please provide a first name.\n'); 
	why += isEmpty(form.LastName, 'Please provide a last name.\n');
	why += checkEmail(form.EmailAddress.value, 'Please enter a valid email address\n');
	why += isNumber(form.PhoneNumber, 3, 'Invalid area code.\n', 'Please enter a three digit area code\n');
	why += isNumber(form.PhoneNumber_2, 3, 'Invalid phone number exchange\n', 'Please provide the three digit phone number exchange.\n');
	why += isNumber(form.PhoneNumber_3, 4, 'Invalid phone number suffix\n', 'Please provide the last four digits of your phone number.\n');
	why += isEmpty(form.JobTitle, 'Please provide your job title.\n');
	why += isEmpty(form.Company, 'Please provide your company name.\n');
	why += isEmpty(form.Industry, 'Please provide the industry of your business.\n');
	why += isEmpty(form.Address, 'Please enter an address.\n');
	why += isEmpty(form.City, 'Please enter the city.\n');
	why += checkDropdown(form.State.selectedIndex, 'Please select a state.\n');
	why += isNumber(form.ZipCode, 5, 'Please enter a valid zip code.\n', 'Please enter a five digit zip code.\n');
	why += checkDropdown(form.ReqType.selectedIndex, 'Please select a request type.\n');
	why += isEmpty(form.ReqDesc, 'Please describe your request.\n');
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

<form onsubmit="return validateForm(this)">
*/

//valid email
function checkEmail (strng, msg) {
	var error = "";
	var filter  = /^[a-zA-Z0-9_\.\-]+\@[a-zA-Z0-9\-\.]+$/;
	if (!(filter.test(strng.value))) {
		error = msg;
	}
	return error;
}

//valid number and length
function isNumber(field, reqLength, msg, msg2) {
	var error = "";
	  if (isNaN(field.value)) {
		  error = msg;
	  } else if (field.value.length < reqLength) {
		  error = msg2;
	  }
	return error;	  
}

// a radio option is selected
function checkRadio(field, msg) {
	var error = "";
	var checked = 0;
	for (i=field.length-1; i > -1; i--) {
		if (field[i].checked) {
			checked++;
		}
	}
	if(checked == 0)
	{
		error = msg;
	}
	return error;	  
}

// non-empty textbox
function isEmpty(field, msg) {
	var error = "";
	  if (field.value.length == 0) {
		 error = msg;
	  }
	return error;	  
}

// valid selector from dropdown list
function checkDropdown(choice, msg) {
	var error = "";
		if (choice == 0) {
			error = msg;
		}    
	return error;
}

function isDifferent(strng) {
    var error = "";
    if (strng != "Can\'t touch this!") {
        error = "You altered the inviolate text area.\n";
    }
}

