
function validateForm(RegTutor) {

var reason = "";

  reason += validateFName(RegTutor.fname);

  reason += validateLName(RegTutor.lname);

  reason += validateContact(RegTutor.telephone);

  reason += validateAddress(RegTutor.address);

  reason += validateDistrict(RegTutor.district);

  reason += validateDob(RegTutor.dob);

  reason += validateSubjects(RegTutor.subjects);

  reason += validateTDate(RegTutor.tdate);

  reason += validateLevel(RegTutor.level);



  if (reason != "") {

    alert("Some fields need correction:\n" + reason);

    return false;

  }
    else {
        return true;
    }
}

function validateFName(fld) {

	var error="";

	if (fld.value == "") {

        fld.style.background = 'Red'; 

        error = "You didn't enter the First Name.\n";

	} else {

	fld.style.background = 'White';

    }

    return error;

}

function validateLName(fld) {

	var error="";

	if (fld.value == "") {

        fld.style.background = 'Red'; 

        error = "You didn't Select The Last Name.\n";

	} else {

	fld.style.background = 'White';

    }

    return error;

}

function validateContact(fld) {
	
	var error="";

	if (fld.value == "") {

        fld.style.background = 'Red'; 

        error = "You didn't enter the Contact Number.\n";

	} else {

	fld.style.background = 'White';

    }

    return error;

}

function validateAddress(fld) {

	var error="";

	if (fld.value == "") {

        fld.style.background = 'Red'; 

        error = "You didn't enter the Address.\n";

	} else {

	fld.style.background = 'White';

    }

    return error;

}

function validateDistrict(fld) {

	var error="";

	if (fld.value == "0") {

        fld.style.background = 'Red'; 

        error = "You didn't enter the District.\n";

	} else {

	fld.style.background = 'White';

    }

    return error;

}

function validateDob(fld) {

	var error="";

	if (fld.value == "") {

        fld.style.background = 'Red'; 

        error = "You didn't enter the Date of Birth.\n";

	} else {

	fld.style.background = 'White';

    }

    return error;

}

function validateSubjects(fld) {

	var error="";

	if (fld.value == "Select") {

        fld.style.background = 'Red'; 

        error = "You didn't enter the Subjects.\n";

	} else {

	fld.style.background = 'White';

    }

    return error;

}

function validateTDate(fld) {

	var error="";

	if (fld.value == "") {

        fld.style.background = 'Red'; 

        error = "You didn't enter the Date.\n";

	} else {

	fld.style.background = 'White';

    }

    return error;

}

function validateLevel(fld) {

	var error="";

	if (fld.value == "0") {

        fld.style.background = 'Red'; 

        error = "You didn't Select the Level.\n";

	} else {

	fld.style.background = 'White';

    }

    return error;

}
