
function check_form()
{

var invalid_name="0123456789+-/><$#@!~`*{}[]\|;"



if(document.cv.name.value=="")
{
alert("Sorry, the name field must not be empty.")
document.cv.name.select();

return false;
}

var name=document.cv.name.value;
var invalid=0;
for(i=0; i<name.length; i++)
{
	for(j=0; j<invalid_name.length; j++)
	{
		if(name.charAt(i)==invalid_name.charAt(j))
		{
			invalid=1;
			break;
		}
	}

}

if(invalid==1)
{
alert("The given name is invalid");
document.cv.name.select();
return false;
}




var name=document.cv.father.value;
var invalid=0;
for(i=0; i<name.length; i++)
{
	for(j=0; j<invalid_name.length; j++)
	{
		if(name.charAt(i)==invalid_name.charAt(j))
		{
			invalid=1;
			break;
		}
	}

}

if(invalid==1)
{
alert("Please give a valid name");
document.cv.father.select();
return false;
}




var name=document.cv.mother.value;
if(name)
{
var invalid=0;
for(i=0; i<name.length; i++)
{
	for(j=0; j<invalid_name.length; j++)
	{
		if(name.charAt(i)==invalid_name.charAt(j))
		{
			invalid=1;
			break;
		}
	}

}

if(invalid==1)
{
alert("Please give a valid name");
document.cv.mother.select();
return false;
}

}



if(document.cv.preAdd.value=="")
{
alert("Sorry, the present address field must not be empty.")
document.cv.preAdd.select();

return false;
}


if(document.cv.perAdd.value=="")
{
alert("Sorry, the permanent address field must not be empty.")
document.cv.perAdd.select();

return false;
}


/*
if(document.cv.phone.value=="")
{
alert("Please Insert the Phone Number")
document.cv.phone.select();

return false;
}

*/

if(document.cv.mobile.value=="")
{
alert("Please Insert the Mobile Number")
document.cv.mobile.select();

return false;
}


/*
if(document.cv.email.value=="")
{
alert("Please Insert the Email Address")
document.cv.email.select();

return false;
}
*/


if(document.cv.nationality.value=="")
{
alert("Please Insert your nationality")
document.cv.nationality.select();

return false;
}


/*
if(document.cv.pic.value=="")
{
alert("Please upload your image")
document.cv.pic.select();

return false;
}
*/


if(document.cv.dob_day.value=="" || document.cv.dob_mon.value=="" || document.cv.dob_year.value=="")
{
alert("Please insert your date of birth")
document.cv.dob_day.focus();

return false;
}




var str="0123456789+, -";
var phone=document.cv.phone.value;

for(i=0; i<phone.length; i++)
{
	for(j=0; j<str.length; j++)
	{
		if(phone.charAt(i)==str.charAt(j))
			{
				ok=1;
				break;
			}
		else
			{
				ok=0;
				continue;
			}

	}

	if(ok==0)
		break;
}

if(ok==0)
{
alert("Sorry, invalid phone number.");
document.cv.phone.select();
return false;
}

if(phone.length<7)
{

alert("Sorry, invalid phone number.");
document.cv.phone.select();
return false;
}


var fax=document.cv.fax.value;

if(fax!="")
{
for(i=0; i<fax.length; i++)
{
	for(j=0; j<str.length; j++)
	{
		if(fax.charAt(i)==str.charAt(j))
			{
				ok=1;
				break;
			}
		else
			{
				ok=0;
				continue;
			}

	}

	if(ok==0)
		break;
}

if(ok==0)
{
alert("Sorry, invalid fax number.");
document.cv.fax.select();
return false;
}

if(fax.length<7)
{

alert("Sorry, invalid fax number.");
document.cv.fax.select();
return false;
}
}





var email=document.cv.email.value;

if(email!="")
{

	len=email.length
	var j=0;
	var k=0;

	for(i=1; i<len;i++)
	{
	if(email.charAt(i)=="@")
	{	j=j+1;
		k=i;
		
	}
	
	}

	if(j==1)
	{
	if(k+2<=len)
	{
	for(i=k; i<len-2; i++)
	{
	
	if(email.charAt(i)==".")
	{
	k=1;
	}
	
	}
	
	}
	}

	if(j==0 || j>1 || k!=1)
	{
	alert ("This is invalid Email Address");
	document.cv.email.select();
	return false;
	}


	
}


if(document.cv.pass.value.length<6)
{
alert("Password should be atleast 6 characters.");
document.cv.pass.select();
return false;
}
if(document.cv.pass.value!=val)
{
alert("Passwords are not matching!");
document.cv.pass.select();
return false;
}


}

