<!--

/***********************************************
* Required field(s) validation v1.10- By NavSurf
* Visit Nav Surf at http://navsurf.com
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function formCheck(formobj,nums){
	switch (nums){
		//	Call Student Form fields
		case 'std':
			// Enter name of mandatory fields
			var fieldRequired = Array("std_narrrrme", "std_fatherName", "std_address", "std_phone", "std_mobile", "std_work_ph", "std_nationaliy", "std_dob", "fee_addmission", "fee_monthly", "e_fee_net", "std_rollno");
			// Enter field description to appear in the dialog box
			var fieldDescription = Array("Student Yoush Name", "Father Name", "Address", "Phone Number", "", "", "Nationality", "Date of birth", "Admission Fee", "Monthly Fee", "Net Fee", "Roll Number");
			break
		//	Call Staff Form fields
		case 'stf' :
			var fieldRequired = Array("stf_name", "stf_fatherName", "stf_address", "stf_phone", "stf_nationaliy", "stf_dob", "stf_salary", "stf_registrationNum");
			var fieldDescription = Array("Employee Name", "Father Name", "Address", "Phone Number", "Nationality", "Date of birth", "Gross Salary", "Employee Num.");
			break;
		case 'feeV':
			var fieldRequired = Array("class_id", "std_rollno", "std_name", "fee_monthly", "e_fee_net");
			var fieldDescription = Array("Select a class", "Student Roll Number", "Student Name", "Student's Monthly Fee", "Student's Net Fee");
			break;
		case 'salV':
			var fieldRequired = Array("stf_designation", "stf_id", "stf_name", "stf_fatherName", "stf_salary", "e_sal_net");
			var fieldDescription = Array("Select a Designation", "Employee Number", "Employee Name", "Father Name", "Gross Salary", "Net Salary");
			break;
	}
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	
	var l_Msg = alertMsg.length;
	j=0;
	fieldCntct = new Array();
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (fieldRequired[i]=='std_phone' || fieldRequired[i]=='std_work_ph' || fieldRequired[i]=='std_mobile'){
			fieldCntct[j] = obj.value;
			if (j==2){
				if (fieldCntct[0]=="" || fieldCntct[1]=="" || fieldCntct[3]=="")
					alertMsg += "\n - Please fill out any one of your contacts !\n\n";
			}
			j++;
		}
		else {
			if (obj){
	//			alert(fieldRequired[i])
				switch(obj.type){
				case "select-one":
					if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
						alertMsg += " - " + fieldDescription[i] + "\n";
					}
					break;
				case "select-multiple":
					if (obj.selectedIndex == -1){
						alertMsg += " - " + fieldDescription[i] + "\n";
					}
					break;
				case "text":
				case "textarea":
					if (obj.value == "" || obj.value == null){
						alertMsg += " - " + fieldDescription[i] + "\n";
					}
					break;
				default:
				}
				if (obj.type == undefined){
					var blnchecked = false;
					for (var j = 0; j < obj.length; j++){
						if (obj[j].checked){
							blnchecked = true;
						}
					}
					if (!blnchecked){
						alertMsg += " - " + fieldDescription[i] + "\n";
					}
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}


function isEMailAddr(elem) {
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (!elem.match(re)) {
		return false;
	} else {
		return true;
	}
}




// -->