
	function validate() {

	var error_msg = "";	//for displaying error messages in the alert box
		error_flag = 0;		//for turning the error to be true
		var focus_place = 0;	//for keping track of the current focus place



		//validate Name for blanks
		if(document.contact.name.value.length == 0) {
			//error
			error_flag = 1;
			if(focus_place == 0) {
				focus_place = 1;
			}
			error_msg = error_msg + "Name cannot be empty\n";
			document.contact.name.value = "";

		}//if  ends
		//validate Email for blanks
		if(document.contact.email.value.length == 0) {
			//error
			error_flag = 1;
			if(focus_place == 0) {
				focus_place = 2;
			}
			error_msg = error_msg + "Email cannot be empty\n";
			document.contact.email.value = "";

		}//if  ends
//validate Coment for blanks
		if(document.contact.comment.value.length == 0) {
			//error
			error_flag = 1;
			if(focus_place == 0) {
				focus_place = 3;
			}
			error_msg = error_msg + "Comment cannot be empty\n";
			document.contact.comment.value = "";

		}//if  ends

		




		//display the error messages gathered
		if(error_flag == 1) {
			alert(error_msg);
			switch(focus_place) {
				case 1:
					document.contact.name.focus();
					break;
				case 2:
					document.contact.email.focus();
					break;
				case 3:
					document.contact.comment.focus();
					break;
				


			} //switch-case ends
			return false;
		}
		else {
			return true;
		} //if-else loop ends

	 } //function validate ends



