// Validator
// Code will take a form, cycle through all fields, and where there is a "required" attribute and 
// the value is "yes", determine if there is data in the field.  For now, that is all this code will 
// do.  If the field is required and the field is empty, the user will be prompted to complete the 
// field and, meanwhile, the form action will be cancelled.

function validator(formname) {
	var form = document.forms[formname];
	var count = 0;
	var message='';
	for(x=0; x<form.elements.length; x++){
		var el = form.elements[x];
		var check = el.required;
		if(check=='yes'){
			if(el.value==''){
				count++;
				message = message + el.name + '\n';
			}
		}
	}
	
	if(count>0){
		alert('There were one or more required fields that were not completed.  Please complete the following fields:\n\n' + message);
		return false;
	}
	else{
		return true;
	}
}