function goodName(string) { 
	if (!string) return false; 										// null string -- error
	var iChars = "*|,\":<>[]{}`~\';()@&$#%^/?_"; 					// unacceptable characters
	for (var i = 0; i < string.length; i++) { 							// loop through each character of the string
		if (iChars.indexOf(string.charAt(i)) != -1) return false;		// if any wrong'un, reject the name
	} 
	return true; 													// well, it's okay, then
} 
function goodEmail(string) { 
	if (!string) return false; 										// null string -- error
	var a = string.split("@");										// split it at the @
	if (a.length != 2) return false;									// if not two pieces, too bad
	var iChars = " *|,\":<>[]{}`~\';()@&$#%^/?";						// unacceptable characters in each piece
	for (var i = 0; i < a[0].length; i++) { 							// check out user name
		if (iChars.indexOf(a[0].charAt(i)) != -1) return false; 		// if any wrong character, tilt
	} 
	var b = a[1].split("\.");											// break domain name at dots
	if (b.length < 2) return false;									// if only one piece, too bad
	var c = b.length - 1;											// last piece index
	if (b[c].length < 2 || b[c].length > 3) return false;				// must end in .xxx or .xx
	for (var i = 0; i < a[1].length; i++) { 							// check out domain name
		if (iChars.indexOf(a[1].charAt(i)) != -1) return false; 		// if any wrong character, tilt
	} 
	return true;														// must be okay, I guess 
} 
function goodPhone(string) { 
	if (!string) return false; 										// null string -- error
	var a = string;													// copy the string
	var iChars = "0123456789- ";									// acceptable characters
	for (var i = 0; i < a.length; i++) { 								// check out user name
		if (iChars.indexOf(a.charAt(i)) == -1) return false; 			// if any wrong character, tilt
	} 
	return true;														// form is valid, at least
} 
function goodAge(string) { 
	if (!string) return false; 										// null string -- error
	var a = string;													// copy the string
	var iChars = "0123456789 ";									// acceptable characters
	for (var i = 0; i < a.length; i++) { 								// check out user name
		if (iChars.indexOf(a.charAt(i)) == -1) return false; 			// if any wrong character, tilt
	} 
	var b = a - 0;
	if (b < 4 || b > 12) return false;
	return true;														// must be okay, I guess 
} 
function checkform(form) { 
	if (goodName(form.username.value) == false) {				// check for a valid user name
		alert("Please enter your name."); 
		form.username.focus(); 
		return false; 
	} 
	if (goodEmail(form.usermail.value) == false) {				// check for a valid e-mail address
		alert("A valid e-mail address is required."); 
		form.usermail.focus(); 
		return false; 
	} 
	if (goodPhone(form.phone.value) == false) {					// check for a valid phone number
		alert("A valid phone number is required."); 
		form.phone.focus(); 
		return false; 
	} 
	if (goodName(form.childname.value) == false) {				// check for a valid child's name
		alert("Please enter the child's name."); 
		form.childname.focus(); 
		return false; 
	} 
	if (goodAge(form.childage.value) == false) {					// check for a valid child's age
		alert("Please enter the child's age -- from 4 to 12."); 
		form.childage.focus(); 
		return false; 
	} 
	if (!(form.grade[0].checked || form.grade[1].checked || form.grade[2].checked || form.grade[3].checked || form.grade[4].checked || form.grade[5].checked || form.grade[6].checked)) {
		alert("Please check the child's grade level.");
		form.grade[0].focus(); 
		return false; 
	}
	return true;
}
//  End of script
