// JavaScript Document

function valname()
{
	str="0123456789~!@#$%^&*()_+-<>?:;[]{}()|.\'\"/\\";
	val=document.myform.name1.value;
	len=val.length;
	if (val=='')
	{
		alert ("please enter your Name");
		document.myform.name1.focus();
		return false;
	}
	for(i=0;i<len;i++)
	 {
  		ch=val.charAt(i);
		if(str.indexOf(ch)!=-1)
		{
			alert ("please enter your Name correctly");
			document.myform.name1.focus();
			document.myform.name1.select();
			return false;
			break;
		}
	}
  return true;
}

function valCompany()
{
	str="0123456789~!@#$%^&*()_+-<>?:;[]{}()|.\'\"/\\";
	val=document.myform.company.value;
	len=val.length;
	if (val=='')
	{
		alert ("please enter your Company name");
		document.myform.company.focus();
		return false;
	}
	for(i=0;i<len;i++)
	 {
  		ch=val.charAt(i);
		if(str.indexOf(ch)!=-1)
		{
			alert ("please enter your Company name correctly");
			document.myform.company.focus();
			document.myform.company.select();
			return false;
			break;
		}
	}
  return true;
}

function valEmail()
{
if (document.myform.email.value=='')
	{
		alert ("please enter your e-mail");
		document.myform.email.focus();
		return false;
	}
	AB=document.myform.email.value
	at=AB.indexOf("@")
	dot=AB.indexOf(".")
 	
 	if(at==-1||dot==-1)
	{
		alert("please enter your e-mail correctly")
		document.myform.email.focus()
		document.myform.email.select()
		return false
	}
	if (at<1)
	{
		alert("please enter your e-mail correctly")
		document.myform.email.focus()
		document.myform.email.select()
		return false
	}
	
	x=AB.substring(at)
	dot2=x.indexOf(".")
	if (dot2<2)
	{
		alert("please enter your e-mail correctly")
		document.myform.email.focus()
		document.myform.email.select()
		return false
	}
	
	z=x.substring(dot2)
	dom=z.length
	if ((dom<3) || (dom>4)||(dom<1))
	{
		alert("please enter your e-mail correctly")
		document.myform.email.focus()
		document.myform.email.select()
		return false
	}

 return true
}
function valPhone()
{
	str="0123456789";
	val=document.myform.tele.value;
	len=val.length;
	if (val=='')
	{
		alert ("please enter your phone number");
		document.myform.tele.focus();
		return false;
	}
	for(i=0;i<len;i++)
	 {
  		ch=val.charAt(i);
		if(str.indexOf(ch)==-1)
		{
			alert ("please enter your phone number correctly");
			document.myform.tele.focus();
			document.myform.tele.select();
			return false;
			break;
		}
	}	
  return true;
}


function valPhone2()
{
	str="0123456789";
	val=document.myform.mob.value;
	len=val.length;
	if (val=='')
	{
		alert ("please enter your mobile number");
		document.myform.mob.focus();
		return false;
	}
	for(i=0;i<len;i++)
	 {
  		ch=val.charAt(i);
		if(str.indexOf(ch)==-1)
		{
			alert ("please enter your mobile number correctly");
			document.myform.mob.focus();
			document.myform.mob.select();
			return false;
			break;
		}
	}	
  return true;
}

function valCategory()
{
	ind=document.myform.category.options.selectedIndex;
	if(ind=='')
	{
		alert("please select a Category");
		document.myform.category.focus();
		return false;
	}
	return true;
}

function valComment()
{
	str="~!@#$%^&*()_+-<>?:;[]{}()|.\'\"/\\";
	val=document.myform.comment.value;
	len=val.length;
	if (val=='')
	{
		alert ("Please enter a your Comment");
		document.myform.comment.focus();
		return false;
	}
	for(i=0;i<len;i++)
	 {
  		ch=val.charAt(i);
		if(str.indexOf(ch)!=-1)
		{
			alert ("Please enter a valid Comment");
			document.myform.comment.focus();
			document.myform.comment.select();
			return false;
			break;
		}
	}
  return true;
}


function valid1()
{
	if(valname()&&valCompany()&&valEmail()&&valPhone()&&valPhone2()&&valCategory()&&valComment())
	{
		return true;
	}
	
return false;
}

function valaddress()
{
	str="~!@#$%^&*()_+-<>?:;[]{}()|.\'\"/\\";
	val=document.myform.address.value;
	len=val.length;
	if (val=='')
	{
		alert ("please enter your Address name");
		document.myform.address.focus();
		return false;
	}
	for(i=0;i<len;i++)
	 {
  		ch=val.charAt(i);
		if(str.indexOf(ch)!=-1)
		{
			alert ("please enter your Address correctly");
			document.myform.address.focus();
			document.myform.address.select();
			return false;
			break;
		}
	}
  return true;
}
function valGender()
{
	ind=document.myform.Gender.options.selectedIndex;
	if(ind=='')
	{
		alert("please select your Gender");
		document.myform.Gender.focus();
		return false;
	}
	return true;
}


function valid2()
{
	if(valname()&&valaddress()&&valEmail()&&valPhone()&&valPhone2()&&valGender()&&valCategory())
	{
		return true;
	}
	
return false;
}

function valpass()
{
	str="0123456789~!@#$%^&*()_+-<>?:;[]{}()|.\'\"/\\";
	val=document.myform.password.value;
	len=val.length;
	if (val=='')
	{
		alert ("please enter your Password");
		document.myform.password.focus();
		return false;
	}
	for(i=0;i<len;i++)
	 {
  		ch=val.charAt(i);
		if(str.indexOf(ch)!=-1)
		{
			alert ("please enter your Password correctly");
			document.myform.password.focus();
			document.myform.password.select();
			return false;
			break;
		}
	}
  return true;
}

function valUname()
{
	str="0123456789~!@#$%^&*()_+-<>?:;[]{}()|.\'\"/\\";
	val=document.myform.username.value;
	len=val.length;
	if (val=='')
	{
		alert ("please enter your Username");
		document.myform.username.focus();
		return false;
	}
	for(i=0;i<len;i++)
	 {
  		ch=val.charAt(i);
		if(str.indexOf(ch)!=-1)
		{
			alert ("please enter your Userame correctly");
			document.myform.username.focus();
			document.myform.username.select();
			return false;
			break;
		}
	}
  return true;
}


function valid3()
{
	if(valUname()&&valpass())
	{
		return true;
	}
	
return false;
}

function valid4()
{
	if(valname()&&valCompany()&&valEmail()&&valPhone()&&valPhone2())
	{
		return true;
	}
	
return false;
}
