// JavaScript Document
// The function to validate the entire form before submitting
function validateForm() {
	if (document.form1.first.value.length < 2 || document.form1.last.value.length < 3 || document.form1.email.value.length < 7 || document.form1.email.value.indexOf("@") < 1 || document.form1.email.value.indexOf(".") < 1){
		window.alert("Please make sure you have completed all fields before submitting the form. The fields containing errors are highlighted in red.");
		return false;
	}
	return true;
}

//To validate the first name
function validateFirst() {
	if (document.form1.first.value.length < 2){
		document.form1.first.style.backgroundColor="#fbcdc9";
		return false;
	}
	document.form1.first.style.backgroundColor="#DfD";
	return true
}

//To validate the Last name
function validateLast() {
	if (document.form1.last.value.length < 3) {
		document.form1.last.style.backgroundColor="#fbcdc9";
		return false;
	}
	document.form1.last.style.backgroundColor="#DfD";
	return true;
}

//To validate the email
function validateEmail() {
	if (document.form1.email.value.length < 7 || document.form1.email.value.indexOf("@") < 1 || document.form1.email.value.indexOf(".") < 1) {
		document.form1.email.style.backgroundColor="#fbcdc9";
		return false;
	}
	document.form1.email.style.backgroundColor="#DfD";
	return true;
}