// JavaScript Document
function hide() {
	window.working.style.display = "none";
	window.student.style.display = "none";
}

function showHide() {
	objValue = document.frmRegistration.occupation.value;
	if(objValue == "Working"){
		window.working.style.display = "block";
		window.student.style.display = "none";
	}
	if(objValue == "Student"){
		window.working.style.display = "none";
		window.student.style.display = "block";
	}
	if((objValue == "Homemaker") || (objValue == "Select")){
		window.working.style.display = "none";
		window.student.style.display = "none";
	}
}

function valid(f)	{
	if (!/^\d*$/.test(f.value))
	{
		alert("Only numbers are allowed!");
		f.value = f.value.replace(/[^\d]/g,"");
		f.focus();
	}
} 

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}

function isProper(string) {
    if (string.search(/^\w+( \w+)?$/) != -1)
        return true;
    else
        return false;
}

/*function getLength() {
	var objValue = document.frmRegistration.whyGCF.value;
	var objLength = objValue.length;
	if(objLength => 10) {
		return false;
	}
	else {
		return true;
	}
}*/

function validateForm(){
	if(document.frmRegistration.firstname.value == "") {
		alert("First Name field cannot be blank !");
		document.frmRegistration.firstname.focus();
		return false;
	}
	if(document.frmRegistration.lastname.value == "") {
		alert("Last Name field cannot be blank !");
		document.frmRegistration.lastname.focus();
		return false;
	}
	if(document.frmRegistration.phone.value == "") {
		alert("Contact number cannot be blank !");
		document.frmRegistration.phone.focus();
		return false;
	}
	if(isProper(document.frmRegistration.phone.value) == false) {
		alert("Please enter a valid contact number.\n\nOnly numbers from 0 to 9 are allowed !");
		document.frmRegistration.phone.focus();
		return false;
	}
	if(document.frmRegistration.email.value == "") {
		alert("Email field cannot be blank !");
		document.frmRegistration.email.focus();
		return false;
	}
	if(isEmail(document.frmRegistration.email.value) == false) {
		alert("Please enter a valid email address !");
		document.frmRegistration.email.focus();
		return false;
	}
	if(document.frmRegistration.occupation.value == "Select") {
		alert("Please select your occupation !");
		document.frmRegistration.firm.focus();
		return false;
	}
	if(document.frmRegistration.occupation.value == "Working") {
		if(document.frmRegistration.company.value == "") {
			alert("Company field cannot be blank !");
			document.frmRegistration.company.focus();
			return false;
		}
		if(document.frmRegistration.designation.value == "") {
			alert("Designation field cannot be blank !");
			document.frmRegistration.designation.focus();
			return false;
		}
	}
	if(document.frmRegistration.occupation.value == "Student") {
		if(document.frmRegistration.college.value == "") {
			alert("College field cannot be blank !");
			document.frmRegistration.college.focus();
			return false;
		}
		if(document.frmRegistration.stream.value == "") {
			alert("Stream/Course field cannot be blank !");
			document.frmRegistration.stream.focus();
			return false;
		}
	}
	if(document.frmRegistration.whyGCF.value == "") {
		alert("Why GCF field cannot be blank !");
		document.frmRegistration.whyGCF.focus();
		return false;
	}
	var objValue = document.frmRegistration.whyGCF.value;
	if(objValue.length > 1500) {
		alert("You have entered "+ objValue.length +" characters.\n\nThe maximum number of characters allowed is 1500.\n\nPlease edit your entry.");
		document.frmRegistration.whyGCF.focus();
		return false;
	}

	return true;
}


/******************************************************/


/*
function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
<INPUT id="txtChar" onkeypress="return isNumberKey(event)" type="text" name="txtChar">

*/






