var theform = document.getElementById("contactForm");

function checkForm(theform) {
	
	theform.firstname.required = true;
	theform.firstname.requiredError = 'The First Name field must be filled in.';
	
	theform.lastname.required = true;
	theform.lastname.requiredError = 'The Last Name field must be filled in.';
	
	theform.email.required = true;
	theform.email.requiredError = 'The Email field must be filled in.';
	
	theform.email.pattern = 'email';
	theform.email.patternError = 'The Email address entered is not valid.';
	

	theform.phone.required = true;
	theform.phone.requiredError = 'The Daytime Phone number field must be filled in.';
	theform.phone.pattern = 'us phone number';
	theform.phone.patternError = 'The Daytime Phone number is not valid.';
	
	var errors = getFormErrors(theform);
	if (errors.length > 0) {
		var errorMessage = 'The form was not submitted due to the following problem' + ((errors.length > 1) ? 's' : '') + ':\n\n';
		for (var errorIndex = 0; errorIndex < errors.length; errorIndex++) {
			errorMessage += '* ' + errors[errorIndex] + '\n';
		}
		errorMessage += '\nPlease fix ' + ((errors.length > 1) ? 'these' : 'this') + ' problem' + ((errors.length > 1) ? 's' : '') + ' and resubmit the form.';
		alert(errorMessage);
		return false;
	}
	
	// no errors: return true
	return true;
}